Small sample taken from senddata.prg:
Code: Select all
// Sockets use sample developed by Enrico M.G.
#include "Fivewin.ch"
FUNCTION MAIN()
LOCAL oWnd
DEFINE WINDOW oWnd
@ 1, 2 BUTTON "Send";
SIZE 100, 50;
ACTION SENDDATA( 25, "209.191.88.254") // yahoo.com - Infinite loop
// ACTION SENDDATA( 25, "209.85.135.111") // smtp.gmail.com - This works good
ACTIVATE WINDOW oWnd
RETURN NIL
STATIC FUNCTION SENDDATA( nPort, cIP, cMsg )
LOCAL oSocket := TSocket():New( nPort )
oSocket:lDebug :=.t.
oSocket:cLogFile:="senddata.log"
oSocket:bConnect := { || oSocket:GetData() , SysWait(1) , oSocket:SendData( "HELO TEST"+CRLF ), SysWait(1),;
oSocket:GetData() , SysWait(1) , oSocket:SendData( "QUIT"+CRLF ), SysWait(1),;
oSocket:GetData() , SysWait(1) , oSocket:End() }
oSocket:Connect( cIP )
RETURN NIL
While with yahoo.com ...04/19/10 02:23:14: Connect Socket handle: 340
04/19/10 02:23:14:
04/19/10 02:23:14: Write Socket handle: 340
04/19/10 02:23:14: Read Socket handle: 340
04/19/10 02:23:16: 220 mx.google.com ESMTP j10sm25406824mue.48
250 mx.google.com at your service
04/19/10 02:23:17: Read Socket handle: 340
04/19/10 02:23:17: Close Socket handle: 340
04/19/10 02:23:18: 221 2.0.0 closing connection j10sm25406824mue.48
I tried manually telnetting the yahoo IP and it kindly reply me a couple of text lines stating that I'm disallowed because I'm on a residential/dynamic IP, then it puts the connection down, but that's not the problem (this is just a sample I made for you to understand the problem).04/19/10 02:26:31: Connect Socket handle: 340
04/19/10 02:26:31:
04/19/10 02:26:32: Sent: -1 Len: 11 Buffer Len: 0 Error: 10057
04/19/10 02:26:32: Sent: -1 Len: 11 Buffer Len: 0 Error: 10057
04/19/10 02:26:32: Sent: -1 Len: 11 Buffer Len: 0 Error: 10057
04/19/10 02:26:32: Sent: -1 Len: 11 Buffer Len: 0 Error: 10057
04/19/10 02:26:32: Sent: -1 Len: 11 Buffer Len: 0 Error: 10057
... infinite
The problem is that looks like a WSA error in SendData() like the above puts tSocket in an infinite loop instead of retrieving those 2 lines of text, that are informative and helpful to know why the 10057 error was triggered, and then closing the socket.
How could I fix it ?
Thanks,
Davide