GuessMyName Posted May 6, 2013 Posted May 6, 2013 HelloI have been training in TCP connections and with the help of some tutorials i have made a Client and a Server here are the Scripts:Client:Tcpstartup() $Socket = TCPConnect(@IPAddress1, 403) If $Socket = -1 Then MsgBox(0, "Error", 'Could not conncet to the server') EndIf ;$SendBytes = TCPSend($Socket, 'Hello, client has made connection with the server') While 1 $Order = InputBox('Send Order', 'Type your order here:') $SendBytes = TCPSend($Socket, $Order) If $SendBytes = 0 Then MsgBox(0, 'Error', 'The packet was not able to reach the server') EndIf WEnd TCPCloseSocket($Socket) TCPShutdown()Server:TCPStartup() $MainSocket = TCPListen(@IPAddress1, 403) While 1 $AcceptedSocket = TCPAccept($MainSocket) If $AcceptedSocket <> -1 Then $RecievedData = TCPRecv($AcceptedSocket, 1000000) If $RecievedData <> "" Then MsgBox(0, 'Data Recived', $RecievedData) TCPCloseSocket($AcceptedSocket) EndIf EndIf WEndI don't know why but the Client does not work i mean this does not work:$Order = InputBox('Send Order', 'Type your order here:') $SendBytes = TCPSend($Socket, $Order)However if i delete this:While 1 $Order = InputBox('Send Order', 'Type your order here:') $SendBytes = TCPSend($Socket, $Order) If $SendBytes = 0 Then MsgBox(0, 'Error', 'The packet was not able to reach the server') EndIf WEndAnd insert this instead (Without comment mark of course), it works (sends the text):;$SendBytes = TCPSend($Socket, 'Hello, client has made connection with the server')Anyone can help me?Thanks
water Posted May 6, 2013 Posted May 6, 2013 Have a look at the examples in the help file for TCPSend and TCPReceive. The examples show how it should be done. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
GuessMyName Posted May 6, 2013 Author Posted May 6, 2013 Ha I corrected my script now it works. Client: HotKeySet('E', '_Exit') TCPStartup() $TCPConncet = TCPConnect(@IPAddress1, 403) If $TCPConncet = - 1 Then Exit ;TCPSend($TCPConncet, 'Close') While 1 $Order = InputBox('Send Order', 'Type your order here:') TCPSend($TCPConncet, $Order) WEnd Func _Exit() Exit EndFunc Server: HotKeySet('~', '_Exit') TCPStartup() $TCPListen = TCPListen(@IPAddress1, 403) Do $TCPAccept = TCPAccept($TCPListen) Until $TCPAccept <> -1 While 1 Do $TCPRecive = TCPRecv($TCPAccept, 1000000) Until $TCPRecive <> "" MsgBox(0, 'Data Recived', $TCPRecive) WEnd Func _Exit() Exit EndFunc
water Posted May 6, 2013 Posted May 6, 2013 Glad you could solve your problem GuessMyName 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
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