Jump to content

Client/server problems


Recommended Posts

Goal: My goal is to create (eventually) a msn type chat.

Problem: i cant figure out how to connect over the internet... i can only connect through my router

Code:

Server:

global $connectedsocket
$ip = @IPAddress1
$port = 65432
;to start tcp services
TCPStartup()
;create listening socket
$mainsocket = TCPListen($ip, $port)
If $mainsocket = -1 Then Exit
;Accept incoming clients and recieve info
While 1
    $connectedsocket = TCPAccept($mainsocket)
    If $ConnectedSocket >= 0 Then
    $ip2 = TCPRecv($connectedsocket,1000000)
    ;create new socket to send connected message
    $socket2 = TCPConnect($ip2, $port)
    TCPSend($socket2, "connected")
    Sleep(2000)
    EndIf
WEnd
TCPCloseSocket($connectedsocket)
TCPCloseSocket($socket2)
TCPShutdown()

Client:

Global $Connected2

$IP = "192.168.2.8"
$Port =65432
$MyIP = @IPAddress1
;Start TCP services
TCPStartup()
;Connecting to main socket
$ConnectedSocket = TCPConnect($IP, $Port)
If @error Then
MsgBox(4096, "Error ", "TCPConnect error: " & @error)
EndIf
;Send info
TCPSend($ConnectedSocket, $MyIP)
; Create a Listening "SOCKET"
$MainSocket2 = TCPListen($MyIP, $Port)
If $MainSocket2 = -1 Then Exit
While 1
$Connected2 = TCPAccept( $MainSocket2)
; look for client connection
$recv = TCPRecv($Connected2, 10000000)
If Not @error Then Endit()
WEnd

Func Endit()
MsgBox(0,"connected",$recv)
TCPCloseSocket($ConnectedSocket)
sleep(300)
TCPCloseSocket($Connected2)
TCPShutdown ( )
exit
EndFunc

Thanks for the time :idea:

Link to comment
Share on other sites

kk well im sorry i was not clear... what i mean is... you should be able to connect one computer to another computer via internet right? This is all i want to do... i want to be able to send information from one computer to another using a server/client method. If you could at all help me it would be much appreciated. And i figured it had been long enough for me to bump. 17 hours?... thats not bad

Link to comment
Share on other sites

Thank you Evilertoaster.

You are right. I am pretty new to all this and am just doing it as a hobby. I am of course still learning and only able to do so through the web. I Barely know anything about networking or the code in autoit for networking and this is why im here :idea: ... Thanks for the info about about port forwarding but unfortunately i still do not understand how to make my code do what i want it to do.

If you can find something similar to what i want i would like to see it , not to steal, but to learn.

It would be much appreciated

Thanks again

Link to comment
Share on other sites

You should first google for good network tutorials before starting. Not only you'll learn a lot, but it will save you from months of pointless frustration and dead ends.

People here are generally very helpful w.r.t. AutoIt and a particular situation, but nobody can possibly teach you networking basics in AutoIt forums.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Everything you need!

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

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