Jump to content

Connect TCP


Recommended Posts

So I coult use this?:

$g_IP = "192.168.0.2"
$MainSocket = TCPListen($g_IP, 65432,  100 )
$g_IP = "192.168.0.3"
$MainSocket2 = TCPListen($g_IP, 65432,  100 )
Enz..
;)

<{POST_SNAPBACK}>

You just need one listening socket, which is the server. Then the clients can connect to this socket.

With TCPAccept you can define which action should be done when a client connects.

Check the the example in the help file, it also deals with a chat program...

Link to comment
Share on other sites

You can accept using an array. There is a script somewhere on the forum wich shows this, its created by larry and its a chat client/server and it works.

It uses socket variable in a array wich makes it possible to have multiple sockets at once.

Only larrys script was for a broadcast like chat wich sends text to all users. You need to have more arrays to be able to send to specific users.

An array per connection is needed I think a multi dimension array even because you to save the text per conversation per user (like a buffer per conversation per user)

for $concounter=1 to $totalcon
  $connection[$concounter]
  for $conversationcounter=1 to $maxconversations[$concounter]
    senddata($concounter, $condata[$concounter][$conversationcounter] [1],$condata[$concounter][$conversationcounter][2])
  next
next

for example sending the array

$condata[connection][connection you chatting with][flag]

flag being 1 contains connection identifier

flag being 2 contains chat data you need to send to that connection

try looking for chat made by larry for multi socket hints

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