Jump to content

AU3 MultiConnect-Socket Server!


dnsi
 Share

Recommended Posts

MULTIPLAYER-SOCKETSERVER :idea:-_-o:)

All you have to do is change the 100 in $link[100] to the number of users you want to connect to your computer.

The port is 9999.

TCPStartup()
Dim $link[100]
$vvv=0
While $vvv<100
    $link[$vvv]=-1
    $vvv=$vvv+1
WEnd
$main=TCPListen(@IPAddress1,9999)
While 1=1
    $i=0
    While $i<100
        If $link[$i]=-1 Then
            $link[$i]=TCPAccept($main)
            ExitLoop
        EndIf
        $i=$i+1
    WEnd
    $j=0
    While $j<100
        If $link[$j]<>-1 Then
            $recv=TCPRecv($link[$j],10000)
            if $recv<>"" Then
                $ddd=0
                While $ddd<100
                    If $link[$ddd]<>-1 Then
                        TCPSend($link[$ddd],$recv)
                    EndIf
                    $ddd=$ddd+1
                WEnd
            EndIf
        EndIf
        $j=$j+1
    WEnd
WEnd

There you go. :whistle:;):P;):D

Link to comment
Share on other sites

MULTIPLAYER-SOCKETSERVER :P;):D

Hi,

A) What does i do ?

;) Does it allow all pc games to be able to run multiple copies ? Even ones that check for duplicate copy run and

terminate it ?

Cough cough proxy cough :whistle:

[quote]I am so clever that sometimes I don't understand a single word of what I am saying.[/quote]

Link to comment
Share on other sites

Whoda buda whata?

:whistle:

English for noobs please!!

I mean i didnt understand was it a yes or no for my questions

Just a server hosting or something ? or just checks total number of ppl connected to ur already hosted game server?

Edited by Graymatter

[quote]I am so clever that sometimes I don't understand a single word of what I am saying.[/quote]

Link to comment
Share on other sites

- Does it allow all pc games to be able to run multiple copies ?

Eehm.. What part of dnsi's post or code made you even think that ?

- Checks total number of ppl connected to ur already hosted game server?

Ost. Same as above.

- Just a server hosting or something ?

Well, that's more like it.

Link to comment
Share on other sites

Hi dnsi,

May be you could modify your code this way, to avoid the magic number (100 in this instance).

TCPStartup()
Dim Const $MAX_CONNECTIONS = 100
Dim $link[$MAX_CONNECTIONS]
$vvv=0
While $vvv<$MAX_CONNECTIONS
    $link[$vvv]=-1
    $vvv=$vvv+1
WEnd
$main=TCPListen(@IPAddress1,9999)
While 1=1
    $i=0
    While $i<$MAX_CONNECTIONS
        If $link[$i]=-1 Then
            $link[$i]=TCPAccept($main)
            ExitLoop
        EndIf
        $i=$i+1
    WEnd
    $j=0
    While $j<$MAX_CONNECTIONS
        If $link[$j]<>-1 Then
            $recv=TCPRecv($link[$j],10000)
            if $recv<>"" Then
                $ddd=0
                While $ddd<$MAX_CONNECTIONS
                    If $link[$ddd]<>-1 Then
                        TCPSend($link[$ddd],$recv)
                    EndIf
                    $ddd=$ddd+1
                WEnd
            EndIf
        EndIf
        $j=$j+1
    WEnd
WEnd

Cubehead

Link to comment
Share on other sites

Perhaps my thread will enlighten you.

http://www.autoitscript.com/forum/index.ph...c=20589&hl=

To allow all possibilities, you should always have a variable like:

CODE

Global $MaxLength = 512; Or any other number

I often set it too 512000 because you never know what amount will come through streams.

As for when you send too much, it is read then if you go over the maximum characters it USUALLY is picked up upon the second recv command as long as no other instance is sent in that .005 odd fraction of a second(if you made you TCP script correctly).

Maximum buffer size :

That is not completely known but the size is proportional to the amount of memory used. Consult the Helpfile on limitations too find it that is availible.

Presumably, since you may get extra values that exceeded the maximum length, you could in theory, read character by character. I have NEVER attempted this and see no need for it, so you may attempt it, please check once again, the list of examples for the Optimized Server /w Client and modify the Client's accepting variable to 1 and see if it works.

Maximum Connections :

Basically, if you do not have it set, then the amount of connections is not set and only limited by the amount of variables you can use or how much you can keep track of. Maximum connection basically inforces a rule that if you exceed the MaxConc setting then your connection is refused. I do not know specifics, I have never tested it that far.

Hopefully this helps you in your TCP thoughts.

It is a decent start, but you're kinda reinventing the wheel to say. Many, many, many servers and test scripts have been made in the past year and AutoIt-ITS(involving TCP) is on hold again due to time restrictions. As soon as I get time the First 1.0 will be availible. But the reality of that happening isn't until christmas or maybe later.

If this helps - great, if it doesn't - so be it.

AutoIt Smith.

Edited by AutoIt Smith
Link to comment
Share on other sites

  • 3 weeks later...

Hi,

I just started on TCP autoit functions, so I've done a mix with the help files to get an handy example.

I'm just wondering why the recieved data is sent back (if I understand correctly) ? Maybe to be captured

by an other process for making 'in-game' things... tell the client 'it's ok I recieved your data!' or I don't know !?!

And would this loop :

DO
$main=TCPAccept(etc..)
Until $main<>-1oÝ÷ Ø"ÈÔÚºÚ"µÍÐÓQS   ÌÌÎÈÝYHYÝ[ÈHÑTTÌÌÎÉÌÌÎÉÌÌÎÉÌÌÎÉÌÌÎÉÌÌÎÉÌÌÎÉÌÌÎÉÌÌÎÉÌÌÎÉÌÌÎÉÌÌÎÉÌÌÎÉÌÌÎÉÌÌÎÂÈÙYHÔXÝ^[[ÛYH    ÑÕRPÛÛÝ[Ë]LÉÝÂÈÝHÔÙXÙÂÏOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOBÔÝ

BÈÙ]ÛÛYH]ØXH[ÂËKKKKKKKKKKKKKKKKKKKKKKKKKBÑ[H    ÌÍÜÞÙÈHÛÛ][YBÈÙ]  ÌÍÜÞTQTÔÈÈÚ]HÑTTËÙHÚ[Ú[ÙHHÈ[YH[È[TYÜÂ[H   ÌÍÜÞTQTÔÈHTYÜÌB[H   ÌÍÛÔHNNNBÈ[]X[^HHXXHÈÙ[HÛÛXÝ[ÛÏOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOB[H ÌÍÐÛÛXÝYÛØÚÙ]HLBÐ][ÈÛÛXÝÈÑTT]]ÈT[ÔÌÎLBÏOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOBÌÍÐÛÛXÝYÛØÚÙ]HÔÛÛXÝ
    ÌÍÜÞTQTÔË ÌÍÛÔ
B[H ÌÍÜÞ]BÈYHÈ[ÜÚÝÈ][ÙÐÞ
LL  ][ÝÑÜ][ÝË  ][ÝÕÔÛÛXÝZ[]ÔÐHÜ    ][ÝÈ  [ÈÜBÈYHÈÈÜÛÜ[[]ÞÜ]BÈÈÙ[ÈHÑTT[ÙBÓÛÜÜ]ÚÚ[ÈÜ]HÈÙ[ÈHÑTTÚ[HBÈ[]ÞÜ][ÛZ]   ÌÍÜÞ]HH[]Þ
    ][ÝÑ]HÜÙ][ÝË  [È [È ][ÝÑ[][ÛZ]ÈHÑTT][ÝÊBÈY^[Ù[H[]ÞÜX]H][ÈÙH^]ÝÜ]ÛÜYÜÜ  ÌÍÜÞ]HH ][ÝÉ][ÝÈ[BBQ[H  ÌÍÛÏPÜBBSÙÐÞ
    ÌÎNÉÌÎNË  ÌÍÛÊBBBQ^]ÛÜBBQ[YÈÙHÚÝ[]H]H[  ÌÍÜÞ]K]È][ÈÙ[]ÝYÚÝÛÛXÝYÛØÚÙ]ÔÙ[
    ÌÍÐÛÛXÝYÛØÚÙ] ÌÍÜÞ]JBÈYHÙ[Z[]Ü[HÛØÚÙ]ÈØÛÛXÝYËKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKBYÜ[^]ÛÜÑ[[Y

Thanx for help me to understand little more:)

EDIT: the $ddd variable is used to send the informations to all clients that are connected :whistle:

I read many scripts from AutoIt Smith and I have understood this one,so my questions are solved.

Edited by clearguy
Link to comment
Share on other sites

Let me give to a tut on TCP/IP.

The server is where every message goes to. The server listens for a incomming connection. when it detects a client it accepts the client in. When a message comes in it needs to be distrubite to everyone in connection thus making a chatroom. The client connects then it sends teh message. When it recives a message it adds to the text field. There Hope You Understand It Better :o:D:nuke::lmao::evil::mad:;)

Link to comment
Share on other sites

So this is some kind of chat server....? I think you are going to have issues if you ever get a lot of connections with a lot of data coming in and out. While the main portion of the script cycles through 9999 times, it is bound to miss a lot of data on the port.

A little reading goes a long way. Post count means nothing.

Link to comment
Share on other sites

So this is some kind of chat server....? I think you are going to have issues if you ever get a lot of connections with a lot of data coming in and out. While the main portion of the script cycles through 9999 times, it is bound to miss a lot of data on the port.

What kind of server it is ???

Look at the title of this topic ;) .

The cycles are there to polling the TCPAccept() to check out if any data has been recieved!

For the miss of data, I don't really know, tests with uber-incoming connections should be done to know it.

If you have any idea or script to make a better server please post it :lmao: .

Clearguy

Link to comment
Share on other sites

What kind of server it is ???

Look at the title of this topic

It still does not make any sense. So, you allow multiple connections to your computer.... Then what?

The cycles are there to polling the TCPAccept() to check out if any data has been recieved!

I realize that. However, with 'uber-incoming connections' you will miss data. At the very least, the data is going to be jumbled up in the buffer and you will have no clue who has sent what.

If you have any idea or script to make a better server please post it :) .

Clearguy

I will, just not right now. It is under development and horribly ugly right now.

A little reading goes a long way. Post count means nothing.

Link to comment
Share on other sites

I will, just not right now. It is under development and horribly ugly right now.

I'm sure that most people who visit these forums regularly can probably write a better server then that. Multi-connection servers are so incredibly easy to create. Blueprints for standard multi connection servers exist, the only problem is they are inside my head. AutoItSmith has shown a few great examples on how to build these servers. You should stop sharing these ugly scripts with anyone.

Link to comment
Share on other sites

I'm sure that most people who visit these forums regularly can probably write a better server then that. Multi-connection servers are so incredibly easy to create. Blueprints for standard multi connection servers exist, the only problem is they are inside my head. AutoItSmith has shown a few great examples on how to build these servers. You should stop sharing these ugly scripts with anyone.

Is this directed at me or the original poster...? The script in this thread is *NOT* mine.

A little reading goes a long way. Post count means nothing.

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