Socket pair

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Socket pair

Santiago A.
I've seen that "accept" functions with socket pairs are deprecated. And
fpsocketpair returns always -1.

How do you get the in and out streams when a server  accepts a new
client connection? I have seen some server examples, like isocksrv.pp,
but only read from client and send nothing back to client.

can anyone point and example with pair of sockets or bidirectional
connection communication?


--
Saludos
Santiago A.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Socket pair

Rainer Stratmann
There is fpaccept

http://www.freepascal.org/docs-html/rtl/sockets/fpaccept.html

But in the example accept is used ... (?!)


Am Montag, 3. Oktober 2016, 10:27:55 schrieb Santiago A.:

> I've seen that "accept" functions with socket pairs are deprecated. And
> fpsocketpair returns always -1.
>
> How do you get the in and out streams when a server  accepts a new
> client connection? I have seen some server examples, like isocksrv.pp,
> but only read from client and send nothing back to client.
>
> can anyone point and example with pair of sockets or bidirectional
> connection communication?
>
>
> --
> Saludos
> Santiago A.
>
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Socket pair

Michael Van Canneyt



On Mon, 3 Oct 2016, Rainer Stratmann wrote:

> There is fpaccept
>
> http://www.freepascal.org/docs-html/rtl/sockets/fpaccept.html
>
> But in the example accept is used ... (?!)

Can you please report this in the bugtracker so I do not forget to correct
this ?

Michael.

>
>
> Am Montag, 3. Oktober 2016, 10:27:55 schrieb Santiago A.:
>> I've seen that "accept" functions with socket pairs are deprecated. And
>> fpsocketpair returns always -1.
>>
>> How do you get the in and out streams when a server  accepts a new
>> client connection? I have seen some server examples, like isocksrv.pp,
>> but only read from client and send nothing back to client.
>>
>> can anyone point and example with pair of sockets or bidirectional
>> connection communication?
>>
>>
>> --
>> Saludos
>> Santiago A.
>>
>> _______________________________________________
>> fpc-pascal maillist  -  [hidden email]
>> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Socket pair

Michael Van Canneyt
In reply to this post by Santiago A.


On Mon, 3 Oct 2016, Santiago A. wrote:

> I've seen that "accept" functions with socket pairs are deprecated. And
> fpsocketpair returns always -1.
>
> How do you get the in and out streams when a server  accepts a new
> client connection? I have seen some server examples, like isocksrv.pp,
> but only read from client and send nothing back to client.
>
> can anyone point and example with pair of sockets or bidirectional
> connection communication?

The same socket descriptor (stream, if you want) can be used for reading and
writing. The descriptor uses different buffers for read and write operations.

I will try to extend the sample programs so this is made more clear.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Socket pair

Paul Breneman
In reply to this post by Santiago A.
On 10/03/2016 03:27 AM, Santiago A. wrote:
> I've seen that "accept" functions with socket pairs are deprecated. And
> fpsocketpair returns always -1.
>
> How do you get the in and out streams when a server  accepts a new
> client connection? I have seen some server examples, like isocksrv.pp,
> but only read from client and send nothing back to client.
>
> can anyone point and example with pair of sockets or bidirectional
> connection communication?

Thanks for reminding me about a socket (and serial) echo example that I
wrote for a work project six months ago.  I'll try to release it here in
the next day or two:
   http://ctrlterm.com/custom.htm

Regards,
Paul
www.ControlPascal.com

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Socket pair

Mark Morgan Lloyd-5
In reply to this post by Michael Van Canneyt
On 03/10/16 12:00, Michael Van Canneyt wrote:
> On Mon, 3 Oct 2016, Santiago A. wrote:

>> can anyone point and example with pair of sockets or bidirectional
>> connection communication?
>
> The same socket descriptor (stream, if you want) can be used for reading
> and
> writing. The descriptor uses different buffers for read and write
> operations.
>
> I will try to extend the sample programs so this is made more clear.

What would be useful in that example would be extracting the IP address
of the server, not just of the client. However when I look at the usage
of Accept() I can't help but notice that it doesn't match what's
described at the top of the page.

http://www.freepascal.org/docs-html/current/rtl/sockets/fpaccept.html

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Socket pair

Paul Breneman
In reply to this post by Paul Breneman
On 10/03/2016 07:24 AM, Paul Breneman wrote:

> On 10/03/2016 03:27 AM, Santiago A. wrote:
>> I've seen that "accept" functions with socket pairs are deprecated. And
>> fpsocketpair returns always -1.
>>
>> How do you get the in and out streams when a server  accepts a new
>> client connection? I have seen some server examples, like isocksrv.pp,
>> but only read from client and send nothing back to client.
>>
>> can anyone point and example with pair of sockets or bidirectional
>> connection communication?
>
> Thanks for reminding me about a socket (and serial) echo example that I
> wrote for a work project six months ago.  I'll try to release it here in
> the next day or two:
>   http://ctrlterm.com/custom.htm
>
> Regards,
> Paul
> www.ControlPascal.com

Just released.  Comments and feedback welcome!

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal