Jump to content

Recommended Posts

Posted

My problem is that if I run my program once compiled and once not and Compiled version is the server. I can't send text out but I can receive text in. The way I have made it is that you can be either the .server or the .client ??? What's wrong ?

While 1

If _IsPressed('0D') And GUICtrlRead($Input) <> '' Then

$Chatcommands = GUICtrlRead($Input)

Local $szIPADDRESS = @IPAddress1

Local $nPORT = 1979

If StringLeft($Chatcommands, 7) = ".server" Then

GUICtrlSetData($Edit, ".server " & $szIPADDRESS & ":" & $nPORT & @CRLF, 1)

$MainSocket = TCPListen($szIPADDRESS, $nPORT, 5)

GUICtrlSetData($Edit, "<Server> Listening to port." & @CRLF, 1)

$TCPServer = "1"

GUICtrlSetData($Input, "")

ElseIf StringLeft($Chatcommands, 7) = ".client" Then

$Chatcommands = StringSplit($Chatcommands, " ")

GUICtrlSetData($Edit, ".client " & $Chatcommands[2] & ":" & $nPORT & @CRLF, 1)

$ConnectedSocket = TCPConnect($Chatcommands[2], $nPORT)

GUICtrlSetData($Edit, "Connecting to server @ " & $Chatcommands[2] & @CRLF, 1)

$TCPServer = "2"

GUICtrlSetData($Input, "")

Else

If $Chatcommands <> "" Then

If $ConnectedSocket >= 0 Then

msgbox(0,"here","client")

TCPSend($ConnectedSocket, $Chatcommands)

GUICtrlSetData($Input, "")

$Chatcommands = ""

Else

msgbox(0,"here","server")

TCPSend($MainSocket, $Chatcommands)

;TCPSend($ConnectedSocket, $Chatcommands)

GUICtrlSetData($Input, "")

EndIf

Else

GUICtrlSetData($Input, "")

$Chatcommands = ""

EndIf

EndIf

Else

EndIf

If $TCPServer = "1" Then

$recvSocket = TCPAccept($MainSocket)

If $recvSocket <> -1 Then

$szIP_Accepted = SocketToIP($recvSocket)

GUICtrlSetData($Edit, "Client Connected. <" & $szIP_Accepted & "> " & $recv & @CRLF, 1)

TCPSend($MainSocket, "HELLO FROM CLIENT")

$TCPServer = "3"

$recv = TCPRecv($recvSocket, 2048)

If $recv <> "" Then

GUICtrlSetData($Edit, "Client > Server <" & $szIP_Accepted & "> " & $recv & @CRLF, 1)

Else

EndIf

Else

EndIf

Else

EndIf

If $TCPServer = "2" Then

$recv = TCPRecv($ConnectedSocket, 2048)

If $recv <> "" Then

GUICtrlSetData($Edit, "Server > Client" & $szIP_Accepted & "> " & $recv & @CRLF, 1)

Else

EndIf

Else

EndIf

If $TCPServer = "3" Then

$recv = TCPRecv($recvSocket, 2048)

If $recv <> "" Then

GUICtrlSetData($Edit, "Client > Server <" & $szIP_Accepted & "> " & $recv & @CRLF, 1)

Else

EndIf

Else

EndIf

WEnd

Posted

How about posting your script in autoit quote? and posting the whole script may also be easier for others to troubleshoot your script

Posted

How about posting your script in autoit quote? and posting the whole script may also be easier for others to troubleshoot your script

I will try the quote but the script is way to big to post the whole thing .. nor do I really want to at this point...

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
×
×
  • Create New...