Jump to content

TCP servers...


Recommended Posts

I was told that the only way to set info or retrieve info from the internet was through a TCP server, so woul anyone try to explain some stuff about how to set up this TCP server?

Im trying to do this:

If someone starts up a gui, than it sends their username to the srver, and other players can retrieve and view the players that had connected, and if they wanted to, "fgiht" them, and i would trigger a msg box on the other PC to accept, when it is accepted, then two do randoms, which are defined by their "weapons" the one with the largest attack number wins, and a msg goes to both players, and the winning player triggers a RegWrite that adds a certain amount of"coins" to the already existing reg write...

i doubt any of this is possible, but it would be awsome if you could leave some tips on setting up a TCP server, or tips on how to do some parts of the above...

if something up there isint possible, but another area is, just let me know how to do the possible one and ill try to find a way around it, im eager to launch my game PvP(player vs. player)

Thank You

-MethodZero

[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Link to comment
Share on other sites

well this is perfectly possible...

Look in the help file under, TCPStartup(), TCPListen(), TCPAccept(), TCPConnect(), and TCPSend().

Here is how to work with them:

;SERVER
TCPStartup() ;call this to make TCP available.
$main = TCPListen(@Ipaddress1, 12345)
while 1
$sock = TCPAccept($main)
$data = TCPRecv($sock, 2048) ;2KB (2048 bytes)
if ($data <> "") Then
MsgBox(0, "", $data)
endif
wend
TCPShutdown() ;this code wont get executed but you get the idea.
oÝ÷ Ù«­¢+Ø(í
1%9P)!½Ñ-åMÐ ÅÕ½Ðí}M¹ÑÅÕ½Ðì°ÅÕ½ÐííÕôÅÕ½Ðì¤)Q
AMÑÉÑÕÀ ¤í͵ѡ¥¹Ì½Ù(ÀÌØíµ¥¸ôQ
A
½¹¹Ð¡%ÁÉÍÌÄ°ÄÈÌÐÔ¤)¥ ÀÌØíµ¥¸ôô´Ä¤Q
AM¡Õѽݸ ¤)Ý¡¥±Ä)ݹ()Õ¹}M¹Ñ ¤)Q
AM¹ ÀÌØíµ¥¸°ÅÕ½ÐíÑÌÌìÌÌìÅÕ½Ðì¤)¹Õ¹

I did'nt test this, just wrote it in here.. lemme know if i did something wrong :) Have'nt done networking in a long time..

Edited by CHRIS95219
Link to comment
Share on other sites

thanks...

the help file just made me way more confused... ok simpler question:

I start up a script, the script sends the word "hello" and someone else can listen, and get a msgbox "hello"

im sory, im very slow at this.. its like me and math...

P.S. for the IP start up mabober, does the ip have to becertain or random?

[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Link to comment
Share on other sites

Im seriously trying my hardest to learn this! gahhh!!!!ok...

I start the TCP...

What the heck is connect? and to what? do i make up an ip?

hmm..(grrr...)

TCPStartup()

$main = TCPListen(@Ipaddress1, 12345)

???

Edited by MethodZero

[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Link to comment
Share on other sites

trial and error isint my thing when it comes to Auto it, because alot of times i freeze myself, do something horrbily wrong, or do something that results in a system restore in safe mode... but ok thanks for the err.. help!

-MethodZero

[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Link to comment
Share on other sites

  • Moderators

trial and error isint my thing when it comes to Auto it, because alot of times i freeze myself, do something horrbily wrong, or do something that results in a system restore in safe mode... but ok thanks for the err.. help!

-MethodZero

That's half the fun, at least when you teach yourself that electro shock therapy isn't fun, you don't go waiving a metal pole out in the rain in the middle of a thunderstorm.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Error: cannot read TCP Funcs.au3

got any ideas?

but really, how do you send the word "hello"

and another computer recieve it?

[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Link to comment
Share on other sites

You must be blind!!!!

Apparently you don't check out the words.

Use a TCP Example Server and use TCP Communicator to talk to the server. Connect on the same IP and Port. Send whatever you want.

More Examples:

Server

Global $MainSocket = -1
Global $ConnectedSocket = -1
Local $MaxConnection = 1; Maximum Amount Of Concurrent Connections
Local $MaxLength = 512; Maximum Length Of String
Local $Port = 1000; Port Number
Local $Server = @IPAddress1; Server IpAddress
TCPStartup()
$MainSocket = TCPListen($Server, $Port)
If $MainSocket = -1 Then Exit MsgBox(16, "Error", "Unable to intialize socket.")
While 1
    $Data = TCPRecv($ConnectedSocket, $MaxLength)
    If $Data = "~bye" Then
        MsgBox(16, "Session Ended", "Connection Terminated.")
        Exit
    ElseIf $Data <> "" Then
; Unconditional Receive
        MsgBox(0, "Received Packet", $Data)
    EndIf
    If $ConnectedSocket = -1 Then
        $ConnectedSocket = TCPAccept($MainSocket)
        If $ConnectedSocket <> -1 Then
; Someone Connected
            TCPSend($ConnectedSocket, "Connected!")
        EndIf
    EndIf
WEnd
Func OnAutoItExit()
    If $ConnectedSocket <> - 1 Then
        TCPSend($ConnectedSocket, "~bye")
        TCPCloseSocket($ConnectedSocket)
    EndIf
    If $MainSocket <> -1 Then TCPCloseSocket($MainSocket)
    TCPShutdown()
EndFunc;==>OnAutoItExit

Sends "Hello"

Global $MainSocket
Local $MaxLength = 512; Maximum Length Of Text
Local $Port = 1000; Port Number
Local $Server = @IPAddress1; Server IpAddress
TCPStartup()
$MainSocket = TCPConnect($Server, $Port)
If $MainSocket = -1 Then Exit MsgBox(16, "Error", "Unable to connect.")
TCPSend($MainSocket, "Hello")
TCPCloseSocket($MainSocket)
TCPShutdown()

Hopefully you figure it out.

Link to comment
Share on other sites

yay.. see i looked but i seriously couldnt figure out what everything was haha... but examples rock!

[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Link to comment
Share on other sites

Instead of forcing the knowledge to work... Lets backtrack real quick. First get some info on what TCP is, what it CAN and CAN'T do, and how to use it. http://en.wikipedia.org/wiki/Transmission_Control_Protocol.

Then.. I can almost guarentee that this will become very simple soon enough :)

Edited by CHRIS95219
Link to comment
Share on other sites

Im seriously trying my hardest to learn this! gahhh!!!!ok...

I start the TCP...

What the heck is connect? and to what? do i make up an ip?

hmm..(grrr...)

TCPStartup()

$main = TCPListen(@Ipaddress1, 12345)

???

Maybe read up on what an ip address is?
# MY LOVE FOR YOU... IS LIKE A TRUCK- #
Link to comment
Share on other sites

What the heck is connect? and to what? do i make up an ip?

maybe you want to read this first: http://www.dummies.com/WileyCDA/DummiesTit...0764517600.html

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

gah.. ok ive run like 50 tests and i messed up the script like 50 times.. how do i recieve info???!!!i did the send script, and another script i messed around with to try and recieve the same message... the one that says hello, only gives me a message that saiys hello.. but i couldnt get my other computer to recieve hello, it just sleeps....or runs in the background though doing nothing...

Try to rcieve:

Global $MainSocket
Local $MaxLength = 512; Maximum Length Of Text
Local $Port = 1000; Port Number
Local $Server = @IPAddress1; Server IpAddress
TCPStartup()
$MainSocket = TCPConnect($Server, $Port)
If $MainSocket = -1 Then Exit MsgBox(16, "Error", "Unable to connect.")
while 1
$sock = TCPAccept($MainSocket)
$data = TCPRecv($sock, 2048) ;2KB (2048 bytes)
if ($data <> "") Then
MsgBox(0, "", $data)
endif
wend
TCPCloseSocket($MainSocket)
TCPShutdown()
oÝ÷ Ù:ò¶-j»lz»Þ­«­¢+Ø)±½°ÀÌØí5¥¹M½­Ðô´Ä)±½°ÀÌØí
½¹¹ÑM½­Ðô´Ä)1½°ÀÌØí5á
½¹¹Ñ¥½¸ôÄì5᥵մµ½Õ¹Ð=
½¹ÕÉɹÐ
½¹¹Ñ¥½¹Ì)1½°ÀÌØí5á1¹Ñ ôÔÄÈì5᥵մ1¹Ñ =MÑÉ¥¹)1½°ÀÌØíA½ÉÐôÄÀÀÀìA½ÉÐ9ÕµÈ)1½°ÀÌØíMÉÙÈô%AÉÍÌÄìMÉÙÈ%ÁÉÍÌ)Q
AMÑÉÑÕÀ ¤(ÀÌØí5¥¹M½­ÐôQ
A1¥ÍѸ ÀÌØíMÉÙÈ°ÀÌØíA½ÉФ)%ÀÌØí5¥¹M½­Ðô´ÄQ¡¸á¥Ð5Í ½à ÄØ°ÅÕ½ÐíÉɽÈÅÕ½Ðì°ÅÕ½ÐíU¹±Ñ¼¥¹Ñ¥±¥éͽ­Ð¸ÅÕ½Ðì¤)]¡¥±Ä(ÀÌØíÑôQ
AIØ ÀÌØí
½¹¹ÑM½­Ð°ÀÌØí5á1¹Ñ ¤(%ÀÌØíÑôÅÕ½ÐíùåÅÕ½ÐìQ¡¸(5Í ½à ÄØ°ÅÕ½ÐíMÍÍ¥½¸¹ÅÕ½Ðì°ÅÕ½Ðí
½¹¹Ñ¥½¸Qɵ¥¹Ñ¸ÅÕ½Ðì¤(á¥Ð(±Í%ÀÌØíѱÐìÐìÅÕ½ÐìÅÕ½ÐìQ¡¸(ìU¹½¹¥Ñ¥½¹°I¥Ù(5Í    ½à À°ÅÕ½ÐíI¥ÙA­ÐÅÕ½Ðì°ÀÌØíѤ(¹%(%ÀÌØí
½¹¹ÑM½­Ðô´ÄQ¡¸(ÀÌØí
½¹¹ÑM½­ÐôQ
AÁÐ ÀÌØí5¥¹M½­Ð¤(%ÀÌØí
½¹¹ÑM½­Ð±ÐìÐì´ÄQ¡¸(ìM½µ½¹
½¹¹Ñ(Q
AM¹ ÀÌØí
½¹¹ÑM½­Ð°ÅÕ½Ðí
½¹¹ÑÌÌìÅÕ½Ðì¤(¹%(¹%)]¹()Õ¹=¹Õѽ%Ñá¥Ð ¤(%ÀÌØí
½¹¹ÑM½­Ð±ÐìÐì´ÄQ¡¸(Q
AM¹ ÀÌØí
½¹¹ÑM½­Ð°ÅÕ½ÐíùåÅÕ½Ðì¤(Q
A
±½ÍM½­Ð ÀÌØí
½¹¹ÑM½­Ð¤(¹%(%ÀÌØí5¥¹M½­Ð±ÐìÐì´ÄQ¡¸Q
A
±½ÍM½­Ð ÀÌØí5¥¹M½­Ð¤(Q
AM¡Õѽݸ ¤)¹Õ¹ìôôÐí=¹Õѽ%Ñá¥Ð(oÝ÷ Ønz0«m+"±»­»§Ö§Ë²jëh×6
Global $MainSocket
Local $MaxLength = 512; Maximum Length Of Text
Local $Port = 1000; Port Number
Local $Server = @IPAddress1; Server IpAddress
TCPStartup()
$MainSocket = TCPConnect($Server, $Port)
If $MainSocket = -1 Then Exit MsgBox(16, "Error", "Unable to connect.")
TCPSend($MainSocket, "Fight Sent")
TCPCloseSocket($MainSocket)
TCPShutdown()
Edited by MethodZero

[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Link to comment
Share on other sites

well, its not entirely my fault!...

[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Link to comment
Share on other sites

Well, in other words, all i really need is that if a person clicks a gui button, it sends to the server "do accept the fight from" & $name & "?" and when/if the person is on, then they would recieve the message, and they click yes, and it sends another one back to the main server....im not asking for you to make it for me(though it would be nice) but i just want to know what exactly to do, in that form....im so confused now...

________________

| BANG HEAD HERE|

|---------++-----------|

|---------++-----------|

|_______________|

*bangs head as punishment*

Edited by MethodZero

[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Link to comment
Share on other sites

*bangs head of wall*

hahahahaha!!!!!

errr... im having some problems with my examples lol... :)

anyways, MethodZero > go look at that wiki page.. it will really help you out with a few things... and also look at AutoIt Smith's Signature for TCP Related stuff... Im sure that will help you too :P

Edited by CHRIS95219
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...