LOULOU Posted July 25, 2006 Share Posted July 25, 2006 TCPStartUp() Global $Server = "smtp.9online.fr" Global $ServerIp = TCPNameToIP($Server) ; Start The TCP Services ;============================================== ; Connect to a Listening "SOCKET" ;============================================== $socket = TCPConnect($ServerIp, 25 ) Msgbox(0,"",$socket) If $socket <> -1 Then Sleep(100) $MainSocket = TCPRecv($socket, 1024) Msgbox(0,"",$mainsocket ) ; Initialize a variable to represent a connection ;============================================== Sleep(100) $sData = "EHLO" & @ComputerName & @CRLF If StringLeft($sData, 3) = "220" Then TCPSend($Socket,"EHLO") If TCPSend($Socket, $sData) > 0 Then Sleep(100) Endif Endif Endif TCPCloseSocket ( $socket ) TCPshutdown() I have trouble with TCPRECV wihch receive nothing. Someone can help me ? Best regards Link to comment Share on other sites More sharing options...
themax90 Posted July 25, 2006 Share Posted July 25, 2006 (edited) You need to put the recv in a While statement While 1 TCPRecv($Socket, 512) WEnd It will not always send immediatly. This is fairly simple. Please check my signature for TCP examples that may help you. Specific example is TCP Client Example below the links in the first post. Edited July 25, 2006 by AutoIt Smith Link to comment Share on other sites More sharing options...
LOULOU Posted July 25, 2006 Author Share Posted July 25, 2006 You need to put the recv in a While statement While 1 TCPRecv($Socket, 512) WEnd It will not always send immediatly. This is fairly simple. Please check my signature for TCP examples that may help you. Specific example is TCP Client Example below the links in the first post. I try with While 1 --Wend but the problem is always the same expandcollapse popupTCPStartUp() Global $Server = "smtp.9online.fr" Global $ServerIp = TCPNameToIP($Server) ; Start The TCP Services ;============================================== ; Connect to a Listening "SOCKET" ;============================================== $socket = TCPConnect($ServerIp, 25 ) Msgbox(0,"",$socket) If $socket <> -1 Then Sleep(100) While 1 $Data = TCPRecv($Socket, 1048) If $Data = "~bye" Then MsgBox(16, "Session Ended", "Connection Terminated.") Exit ElseIf $Data <> "" Then ; Unconditional Receive MsgBox(0, "Received Packet", $Data) EndIf WEnd ; Initialize a variable to represent a connection ;============================================== Sleep(100) $sData = "EHLO" & @ComputerName & @CRLF If StringLeft($sData, 3) = "220" Then TCPSend($Socket,"EHLO") If TCPSend($Socket, $sData) > 0 Then Sleep(100) Endif Endif Endif TCPCloseSocket ( $socket ) TCPshutdown() Link to comment Share on other sites More sharing options...
themax90 Posted July 25, 2006 Share Posted July 25, 2006 Please take a serious look at my examples and even use the TCP Client Example. You seem to stray from the fact that you may need a GUI for sending information. You must be able to send the command while listening. Review the help file and the TCP Client/ TCP Server Communicator for help. Link to comment Share on other sites More sharing options...
/dev/null Posted July 25, 2006 Share Posted July 25, 2006 I have trouble with TCPRECV wihch receive nothing. Someone can help me ?well, I did a telnet to that server on port 25. It simply does not answer, so it's no wonder TCPRecv() does not receive anything!CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
nfwu Posted July 25, 2006 Share Posted July 25, 2006 (edited) The TCPAccept function is missing. TCPStartup() Global $Server = "smtp.9online.fr" Global $ServerIp = TCPNameToIP($Server) ; Start The TCP Services ;============================================== ; Connect to a Listening "SOCKET" ;============================================== $mainsocket = TCPConnect($ServerIp, 25) MsgBox(0, "", $socket) While 1 $socket = TCPAccept($mainsocket) If $socket <> - 1 Then Sleep(100) Do $recvdata = TCPRecv($socket, 1024) Until $recvdata <> "" MsgBox(0, "", $recvdata) ; Initialize a variable to represent a connection ;============================================== Sleep(100) $sData = "EHLO" & @ComputerName & @CRLF If StringLeft($sData, 3) = "220" Then TCPSend($socket, "EHLO") EndIf If TCPSend($socket, $sData) > 0 Then Sleep(100) EndIf EndIf WEnd TCPCloseSocket($mainsocket) TCPShutdown() #) edit: Did a Tidy on the script. Edited July 25, 2006 by nfwu TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
/dev/null Posted July 25, 2006 Share Posted July 25, 2006 The TCPAccept function is missing.TCPAccept() is only for servers. He is trying to write a client! If TCPAccept() was missing, then TCPListen() is missing as well!CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
nfwu Posted July 25, 2006 Share Posted July 25, 2006 Ah... my apologies. I thought he was writing a server. @LOULOU: Try sending something to the server first. #) TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
/dev/null Posted July 25, 2006 Share Posted July 25, 2006 Ah... my apologies.I thought he was writing a server.No problem.@LOULOU: Try sending something to the server first.I'm pretty sure the problem is somewhere else. As I said earlier:I did a telnet to that server on port 25. It simply does not answer, so it's no wonder TCPRecv() does not receive anything!CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now