Jump to content

TCP - conecting


GoFor
 Share

Recommended Posts

Hi guys, i Have problem with connecting to server. This is the part of code:

Client:

#include <GUIConstants.au3>


TCPStartup() ;start usługi TCP


Global $serwer1 = '749.0.0.3'
Global $serwer2 = Null
Global $serwer3 = Null
Global $port = '32399'

.

.

.

$serwer=GUICtrlRead($serwery)
if $serwer = 'serwer 1' Then
 $socket = TCPConnect($serwer1, $port) 
   ElseIf $serwer = 'serwer 2' Then
 $socket = TCPConnect($serwer2, $port) 
   ElseIf $serwer = 'serwer 3' Then
 $socket = TCPConnect($serwer3, $port) 
 EndIf
If $socket = -1 Then ;jeśli $socket = -1, komunikat o błędach
MsgBox(16, "Błąd:", "Połączenie z serwerem nie można ustalić!") ;;just error
EndIf
 $sendedBytes = TCPSend($socket, $wiadomosc)
 If $sendedBytes = 0 Then 
MsgBox(16, "Error", "Pakiet nie może być wysłany.") ;;just error
 EndIf
 TCPCloseSocket($socket) 
 TCPShutdown()

Server:

TCPStartup()
$mainsocket = TCPListen("749.0.0.3", 32399)
While 1 
   $acceptedSocket = TCPAccept($mainsocket) 
   If $acceptedSocket <> -1 Then 
 $receivedData = TCPRecv($acceptedSocket, 1024) 
      MsgBox(64, "Wiadomość otrzymana!", "Otrzymałem wiadomość: " & $receivedData)
      TCPCloseSocket($acceptedSocket) 
   EndIf
WEnd

Sorry for Polish variables and strings. Why it doesnt work guys?

Link to comment
Share on other sites

$mainsocket = TCPListen("749.0.0.3", 32399)

Unless there's something obvious that I'm missing, "749.0.0.3" is not a valid address.

 

[EDIT] On a side note - your English is pretty good, no need to apologize.  However, you might be interested do know that you probably want "$server", not "$sewer" since a "sewer" is what a toilet connects to. :)

 

[EDIT2] s/you're/your/ .  (Better than my English apparently... ;) )

Edited by mrider

How's my riding? Dial 1-800-Wait-There

Trying to use a computer with McAfee installed is like trying to read a book at a rock concert.

Link to comment
Share on other sites

  • Developers

But what ip i should use guys?

:think: Shouldn't you know that answer?

Use one of the active IP addresses of your server.

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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...