Shanheavel Posted December 18, 2010 Share Posted December 18, 2010 (edited) Hello!I'm trying to make a client with:$IP = 91.203.223.59$Port = 7171- Send one message (for example "abcdef...") to $IP and $Port,- Recive one message from $IP and $PortMy script:$IP = "91.203.223.59" ; Server IP$Port = 7171 ; Server Port;==============================================TCPStartUp()$PacketData = "Hello server!!!" ; Packet to send$socket = TCPConnect($IP, $Port) If @error Then MsgBox(4112, "Error", "TCPConnect failed with WSA error: " & @error) Exit EndIf TCPSend($socket, $PacketData) $listen = TCPListen($IP, $Port) $ConnectedSocket = TCPAccept($listen)MsgBox(32, $IP, "Recv from server: " & TCPRecv($ConnectedSocket, 2048))What is wrong? Edited December 18, 2010 by Adrian777 Link to comment Share on other sites More sharing options...
twitchyliquid64 Posted December 18, 2010 Share Posted December 18, 2010 (edited) Try: $IP = "91.203.223.59" ; Server IP $Port = 7171 ; Server Port ;============================================== TCPStartUp() $PacketData = "Hello server!!!" ; Packet to send $listen = TCPListen($IP, $Port) $socket = TCPConnect($IP, $Port) If @error Then MsgBox(4112, "Error", "TCPConnect failed with WSA error: " & @error) Exit EndIf TCPSend($socket, $PacketData) Sleep(1500) ;Just give it some time for the request to cum $ConnectedSocket = TCPAccept($listen) MsgBox(32, $IP, "Recv from server: " & TCPRecv($ConnectedSocket, 2048)) Notice the script starts lsitening BEFORe it connects. Maybe speed is your problem. If not, I need more information and don't forget to port forward. -Hypoz Edited December 18, 2010 by hyperzap ongoing projects:-firestorm: Largescale P2P Social NetworkCompleted Autoit Programs/Scripts: Variable Pickler | Networked Streaming Audio (in pure autoIT) | firenet p2p web messenger | Proxy Checker | Dynamic Execute() Code Generator | P2P UDF | Graph Theory Proof of Concept - Breadth First search Link to comment Share on other sites More sharing options...
Shanheavel Posted December 18, 2010 Author Share Posted December 18, 2010 Thanks for reply. Sending is good but receiving doesn't work. Link to comment Share on other sites More sharing options...
twitchyliquid64 Posted December 18, 2010 Share Posted December 18, 2010 Thanks for reply. Sending is good but receiving doesn't work. Try this then. $IP = "91.203.223.59" ; Server IP $Port = 7171 ; Server Port ;============================================== TCPStartUp() $PacketData = "Hello server!!!" ; Packet to send $listen = TCPListen($IP, $Port) $socket = TCPConnect($IP, $Port) If @error Then MsgBox(4112, "Error", "TCPConnect failed with WSA error: " & @error) Exit EndIf TCPSend($socket, $PacketData) Sleep(1500) ;Just give it some time for the request to cum $timeout_timer = Timerinit() $callout = False While $callout = False $sock2 = TCPAccept($listen) if $sock2 <> -1 then MsgBox(32, $IP, "Recv from server: " & TCPRecv($ConnectedSocket, 2048)) exitloop endif $data = TCPRecv($socket, 2048) if $data <> "" then MsgBox(32, $IP, "Recv from server ON CLIENT SOCKET, NOT SERVER SOCKET: " & $data) exitloop endif if TimerDiff(timeout_timer) > 5000 then $callout = True Wend if $callout = True then MsgBox(32, $IP, "FAILED: no data or connection on either socket.") Try that and check you port forwarding and firewall settings on CLIENT. ongoing projects:-firestorm: Largescale P2P Social NetworkCompleted Autoit Programs/Scripts: Variable Pickler | Networked Streaming Audio (in pure autoIT) | firenet p2p web messenger | Proxy Checker | Dynamic Execute() Code Generator | P2P UDF | Graph Theory Proof of Concept - Breadth First search Link to comment Share on other sites More sharing options...
twitchyliquid64 Posted December 18, 2010 Share Posted December 18, 2010 Some of the code is wrong; simple syntax; easy for you to fix (not near autoit compiler and stuff) I can access the server. What is the server? what protocol is it? what are you trying to do??? I can't help you without that. ongoing projects:-firestorm: Largescale P2P Social NetworkCompleted Autoit Programs/Scripts: Variable Pickler | Networked Streaming Audio (in pure autoIT) | firenet p2p web messenger | Proxy Checker | Dynamic Execute() Code Generator | P2P UDF | Graph Theory Proof of Concept - Breadth First search 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