TheByteWorks

    Quality ready made and affordable custom software

Home
What's new here

Software

PHP Serial
rsterm
Easy Control
Rack Designer
EzCom2Web

Quick Texts
Wallpaper Slideshow

Articles

All articles
WS2300 weather station PHP project
Your own terminal in 17 lines
PC PIC Voltmeter
Network messenger in 22 lines
Phone Dialer

Download
Purchase

Support

Details
E-mail

Copyright 2001-2016
© Cosmin Buhu

  Network messenger
Screenshot

Network messenger in 22 lines

Example for TCP/IP communications.

In this project we'll build a messenger application, capable to send and receive string message
over a TCP/IP network.

Step 1
Design rack in Rack Designer, or you may download example archive which contains the
messenger rack (see screenshot on the left side of this article).

Step 2
Write or open in Easy Control this script code :
#Open rack. Don't forget to write the correct path to file
openrack (d:\messenger\messenger.res)
start:
#Wait untill activate check led to be checked
repeat
send=0
until (activate<>0)
#Open TCP server
openssrv (localport)
again:
#Check if activate was not uncheck (this is in the main loop)
if (activate==0)
#If it is so, close TCP server and go to start
closessrv ()
goto start
endif
#Check if we have to send a message (button send is pressed)
if (send==1)
#If yes, send message
writesock (remoteip,remoteport,tosend)
send=0
endif
#Check if we have something in the TCP buffer
myread=readsock ()
length=len (myread)
#If we have, display the message and flush the TCP buffer
if (length<>0) received=myread
flushsock ()
endif
#And go again, and again...
goto again

Don't forget to fill local port, remote ip and remote port with correct data.
For local testing (on the same machine), start two instances of Easy Control and
fill the fields as it is in the screenshot (same IP address: 127.0.0.1, reversing
the ports).

Download this project :
Network messenger

More ?
Well, check for data integrity, timeouts, visual enhancements,...

Enjoy !