Sign in to follow this  
Followers 0
CodyBarrett

TCP questions

4 posts in this topic

maybe i didnt seach the right phrase but i have a few quick questions;

1.how manny virtual sockets can one computer handle?

2.how do you check if a socket in a multiclient TCP is empty?

thank you

Share this post


Link to post
Share on other sites



maybe i didnt seach the right phrase but i have a few quick questions;

1.how manny virtual sockets can one computer handle?

2.how do you check if a socket in a multiclient TCP is empty?

thank you

try this Global $CurrentSocket = 0
Global $ListenSocket
Global $ConnectedSocket[16]

$TCP = TCPStartup()
If $TCP = 0 Then
    MsgBox(0, "Error", "Unable to startup TCP Services!")
    Exit
EndIf

$ListenSocket = TCPListen(@IPAddress1,1777,16)
If $ListenSocket = -1 Then
    MsgBox(0, "ERROR", "Unable to start listening on port 1777")
    Exit
EndIf
  
While 1
    $ConnectedSocket[$CurrentSocket] = TCPAccept($ListenSocket)
    If $ConnectedSocket[$CurrentSocket] <> -1 Then
        $CurrentSocket = $CurrentSocket + 1
    EndIf
    For $INDEX = 0 To 15
        If $ConnectedSocket[$INDEX] <> -1 Or $ConnectedSocket[$INDEX] <> "" Then
            $Recv = TCPRecv($ConnectedSocket[$INDEX],1024)
            If $Recv <> "" Then
            ...
            EndIf
        EndIf
    Next
    Sleep(20)
WEnd

Share this post


Link to post
Share on other sites

hmm ill take a look into that later, i got stuff to do now :) thank you for responding

and the question #2? anyone know how many virtual sockets there are? or what?

Share this post


Link to post
Share on other sites

The number of sockets can be a big number. Check how many subscripts can be an array on your computer.


When the words fail... music speaks

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