Sign in to follow this  
Followers 0
GoFor

TCP - conecting

12 posts in this topic

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?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

Oh ;) You're right with ""749.0.0.3" is not a valid address.". But there isn't "sewer" but "serwer". "serwer" means in english "server". Thanks for help bro ;)

Share this post


Link to post
Share on other sites

LOL.  I looked at "$serwer" and saw "$sewer".  I guess it shows where my thoughts are!  Anyway, I hope that helped. :)

1 person likes this

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.

Share this post


Link to post
Share on other sites

But what ip i should use guys?

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I must use ip of my computer?

Share this post


Link to post
Share on other sites

But i want to use TCP. And if i want to connect from my one pc to the other pc, what ip i must use?

Share this post


Link to post
Share on other sites

I have a variable ip (translate google ;/) (changing ip?) and it will work too? Because I tried it in my 1 pc and it doesnt work ;/

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