Jump to content

TCP troubles


Recommended Posts

So I have it so that the client will connect to the server, but once it sends the data I can't send new data to the server or the server wont receive new data not sure what the problem is but I need it to show the last data that was sent from the client.

Server:

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

TCPStartup()

$TCPListen = TCPListen(@IPAddress1, 403)

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Server", 121, 81)
$Label1 = GUICtrlCreateLabel("Data Recieved:", 0, 0, 79, 17)
$Label2 = GUICtrlCreateLabel("", 0, 16, 116, 57)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Do
    $TCPAccept = TCPAccept($TCPListen)
Until $TCPAccept <> -1

Do
    $TCPRecive = TCPRecv($TCPAccept, 1000000)
Until $TCPRecive <> ""

GUICtrlSetData($Label2, $TCPRecive)



While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Client

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

TCPStartup()
$TCPConnect = TCPConnect(@IPAddress1, 403)
If $TCPConnect = -1 Then Exit

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Client", 111, 97, -1, -1)
$Input1 = GUICtrlCreateInput("", 8, 40, 89, 21)
$Button1 = GUICtrlCreateButton("Send", 16, 64, 75, 25, $WS_GROUP)
$Label1 = GUICtrlCreateLabel("Please Send Your", 8, 0, 89, 17)
$Label2 = GUICtrlCreateLabel("Data to the Server", 8, 16, 91, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $data = GUICtrlRead($Input1)
            TCPSend($TCPConnect, String($data))
    EndSwitch
WEnd
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...