Network Help
I am trying to use the PropTCP driver with a Gadget Gangster E-Net module. I have the demo webserver program running so I know the hardware works.
Ultimately what I want to do is to have the prop connect to a (PC based) server, send a piece text and read a valid / invalid result back from the server.
1) Is it possible to try and connect to an IP address and have it succeed or fail depending on whether there is a server listening or not ?
2) Am I using the correct unit for this (api_telnet_serial) or is there something more appropriate ?
3) Has anyone done this or can point me in the right direction or offer some sample code ?
Thanks
Paul
Ultimately what I want to do is to have the prop connect to a (PC based) server, send a piece text and read a valid / invalid result back from the server.
1) Is it possible to try and connect to an IP address and have it succeed or fail depending on whether there is a server listening or not ?
2) Am I using the correct unit for this (api_telnet_serial) or is there something more appropriate ?
3) Has anyone done this or can point me in the right direction or offer some sample code ?
Thanks
Paul

Comments
Any help would be really appreciated.
Paul
CON _clkmode = xtal1+pll16x _xinfreq = 5_000_000 rxlen = 128 txlen = 2048 OBJ lcd : "serial_Lcd" ' Parallax Serial LCD Driver v1.2 kb : "keyboard" enet : "api_telnet_serial" ' Ethernet module DAT mac_addr byte $02, $20, $00, $00, $00, $15 ' device mac address, must be unique long ip_addr byte 10, 0, 0, 252 ' device's ip address ip_subnet byte 255, 255, 255, 0 ' network subnet ip_gateway byte 10, 0, 0, 250 ' network gateway (router) ip_dns byte 10, 0, 0, 250 ' network dns ip_serv byte 10, 0, 0, 250 ' remote server for propeller client port_serv byte 80 ' via telnet port VAR byte tcp_webrx1[rxlen] ' buffers for socket 1 byte tcp_webtx1[txlen] long ServerIP ' remote server's IP, packed in a 32 bit number word ServerPort ' remote server port number PUB main kb.start(26, 27) 'start the keyboard enet.start(7, 6, 5, 4, -1, -1, @mac_addr, @ip_addr) LCD.init(8,9600, 4) LCD.cls 'Clear screen LCD.backlight(true) ' Backlight on LCD.gotoxy(0, 0) ' Home position LCD.str(string("Trying to connect")) ServerIP := (byte[@ip_serv]<<24)+(byte[@ip_serv+1]<<16)+(byte[@ip_serv+2]<<8)+byte[@ip_serv+3] ServerPort := byte[@port_serv] enet.connect(ServerIP, ServerPort, @tcp_webrx1, rxlen, @tcp_webtx1, txlen) enet.resetBuffers enet.WaitConnectTimeout(2000) LCD.cls 'Clear screen LCD.gotoxy(0, 0) ' Home position if enet.IsConnected LCD.str(string("Success")) else LCD.str(string("CONNECTION FAILED")) REPEAT LCD.putc(kb.getkey)a) There was a delay between calling the .start method and the .connect method
b) The .connect method is within the loop of the program so that pressing a key will re-try the connection.
Now, the first connection attempt invariably fails but subsequent attempts (mostly) work fine.
Tom
As I understand the code, the enet.WaitConnectTimeout(2000) loops until either the connection is made or the timeout (of 2000 mS) elapses. I have tried longer values without success.
Once the initial failure is out of the way, the connection occurs virtually immediately.
Paul