Re: Simple Socket Setup
- Posted by Brian Jackson <bjackson at 2FARGON.HYPERMART.NET> Jan 10, 2000
- 505 views
On Mon, 10 Jan 2000 10:43:37 -0500, Andy Briggs <briggsan at HOTMAIL.COM> wrote: >I am trying to figure out how to set up >a transfer from one computer to another. >I will use two separate progs; one for >Tx and one for Rx. I would like to know >the simplest possible program to send a >3 digit number from Tx to Rx whenever an >event ocurrs (A button is pushed). >I would HUGELY appreciate it if someone >could show me how to create such a >program using sockets. > >Thanks... Andy Andy, I wrote a generic server that will demonstrate how to use the SM_ASYNC 'event' to handle opening, reading, and closing connections to a remote machine. You can find it in the downloads section of my site at http://2fargon.hypermart.net. As for the client, include srvsckip.ew (included with the server demo), and do something like this: -- UNTESTED CODE! USE AT YOUR OWN RISK! -- requres win32lib.ew and srvsckip.ew global atom mySocket procedure onOpenMainWindow() -- executes at the onOpen event object errorRtn errorRtn = WsockInit() -- initialize winsock if errorRtn then abort(1) -- couldn't initialize end if mySocket = WsockCallSocket("127.0.0.1",80) -- the two parameters are IP address and port number. Set them as -- appropriate for your server program end procedure procedure onClickButton() -- called when the button is clicked sequence data object errorRtn data = "123" -- or use whatever logic you like to format the data errorRtn = WsockSendData(mySocket, data) -- this function sends the sequence data to the server end procedure -- end code Hope this helps, and feel free to ask lots more questions. I know I had to when I was trying to figure all this stuff out! Brian