Sign in to follow this  
Followers 0
Klovis

TCP troubles

2 posts in this topic

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

Share this post


Link to post
Share on other sites



You better not try to reinvent the wheel - use this UDF and it will work very well:


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
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
Sign in to follow this  
Followers 0