🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.socket
9 messages
9 total messages Started by Orlando Lopez Mon, 05 Jul 2004 20:15
Creating Socket dynamically
#5677
Author: Orlando Lopez
Date: Mon, 05 Jul 2004 20:15
9 lines
996 bytes
Hi to all,

what would have to do to create sockets dynamically(client and
server). My problem is that I have to create many sockets
 connections at run time. What can I do?


Orlando.
Re: Creating Socket dynamically
#5717
Author: Omar Zelaya
Date: Mon, 05 Jul 2004 20:19
23 lines
1595 bytes
You can do this using TServerSocket:

SvrSocket = new TServerSocket(NULL);
SvrSocket->Active = false;
SvrSocket->Port = PortNo;
SvrSocket->ServerType = stThreadBlocking;
SvrSocket->ThreadCacheSize = CacheSize;
SvrSocket->OnGetThread = ServerSocketGetThread;
SvrSocket->OnClientConnect = ServerSocketClientConnect;
SvrSocket->OnClientDisconnect = ServerSocketClientDisconnect;
SvrSocket->Active = true;

"Orlando Lopez" <hlopezrd@hotmail.com.do> wrote in message
news:40e9b6fd$1@newsgroups.borland.com...
>
> Hi to all,
>
> what would have to do to create sockets dynamically(client and
> server). My problem is that I have to create many sockets
>  connections at run time. What can I do?
>
>
> Orlando.
Re: Creating Socket dynamically
#5679
Author: Remy Lebeau (TeamB)
Date: Mon, 05 Jul 2004 21:56
13 lines
1240 bytes
"Orlando Lopez" <hlopezrd@hotmail.com.do> wrote in message
news:40e9b6fd$1@newsgroups.borland.com...

> what would have to do to create sockets
> dynamically(client and server).

That depends - are you trying to use particular socket components, or are
you accessing the socket API directly?  If components, then which ones
exactly?


Gambit
Re: Creating Socket dynamically
#5681
Author: Orlando Lopez
Date: Mon, 05 Jul 2004 22:14
11 lines
1020 bytes
Hi Gambit,
>you accessing the socket API directly?  If components, then 
>which ones
>exactly?

I'm using VCL components TServerSocket and TClientSocket.



Orlando.
Re: Creating Socket dynamically
#5682
Author: Remy Lebeau (TeamB)
Date: Tue, 06 Jul 2004 00:08
43 lines
1945 bytes
"Orlando Lopez" <hlopezrd@hotmail.com> wrote in message
news:40e9d2c3$1@newsgroups.borland.com...

> I'm using VCL components TServerSocket and TClientSocket.

Then you instantiate them like any other dynamically-allocated class - via
the 'new' operator - ie:

    TClientSocket *client = new TClientSocket(this);
    client->Address = "207.14.32.23";
    client->Port = 12345;
    client->OnRead = ReadFromClient;
    //...
    client->Open();
    //...
    client->Close();
    delete client;

    void __fastcall TMyForm::ReadFromClient(Object* Sender,
TCustomWinSocket* Socket)
    {
        //...
    }


    TServerSocket *server = new TServerSocket(this);
    server->Port = 12345;
    server->OnClientRead = ReadFromServerClient;
    //...
    server->Open();
    //...
    server->Close();
    delete server;

    void __fastcall TMyForm::ReadFromServerClient(TObject* Sender,
TCustomWinSocket* Socket)
    {
        //...
    }


Gambit
Re: Creating Socket dynamically
#5685
Author: Orlando Lopez
Date: Tue, 06 Jul 2004 15:39
12 lines
1253 bytes
Thanks a lot Gambit,
>Then you instantiate them like any other dynamically-allocated class - via
>the 'new' operator

so, I guess that I can create all Client and Server socket
that I want?? like an array of connections (Client and 
Server)?



Orlando.
Re: Creating Socket dynamically
#5686
Author: Hans Galema
Date: Tue, 06 Jul 2004 15:48
16 lines
1577 bytes
Orlando Lopez wrote:

> so, I guess that I can create all Client and Server socket
> that I want?? like an array of connections (Client and 
> Server)?

How many servers do you need in one application ? You can use
one TServerSocket on a specific port and it will handle all
connections from all clients. See the property
TServerSocket::Socket::Connections[];

How many clients do you need in one application ?

Do you need a server and client(s) in one application?

Hans.
Re: Creating Socket dynamically
#5687
Author: Remy Lebeau (TeamB)
Date: Tue, 06 Jul 2004 17:58
12 lines
1285 bytes
"Orlando Lopez" <hlopezrd@hotmail.com.do> wrote in message
news:40eac7a7$1@newsgroups.borland.com...

> so, I guess that I can create all Client and Server socket
> that I want?? like an array of connections (Client and
> Server)?

Yes.


Gambit
Re: Creating Socket dynamically
#5690
Author: Orlando Lopez
Date: Tue, 06 Jul 2004 18:51
15 lines
1413 bytes
Hi Hans,
>How many clients do you need in one application ?
>
>Do you need a server and client(s) in one application?
>

I will use many TSocketClient as Client will be connected, and
for the TServerSocket, you are right, I can use one
TServerSocket for many connections, but for some machine in my
network I will use another port. My idea is  dedicate a port 
for a specific task.


Orlando.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads