|
|
bind() and connect() issues [Newbie] #2
Hi,
I have a client which executes a bind() call before a connect() call. Is
this ok to do?
Most books I read have the steps for server as
socket->bind->listen->accept->recv->send->close and for client its
socket->connect->send->recv->close. I want my client bound to a known port,
because later I need some other process to connect to my client which brings
me to my second question - on the client side once I do
socket->bind->connect, now how do I close this connection? I do not want to
do close() because later in the client I want to be able to listen to
incoming requests on the port that I have just bound the client socket to.
Also, what is the effect of executing a recv() call expecting more bytes
than have been send(). For example if A sends B 10 bytes and B does a recv()
for 30 bytes, whats going to happen at B - What is the default behaviour in
this case? Will it block? Will it just read the 10 bytes and proceed?
|
|
0
|
|
|
|
Reply
|
Rookie
|
10/4/2004 7:41:41 AM |
|
"Rookie" <dominicjoseph@rediffmail.com> writes:
>I have a client which executes a bind() call before a connect() call. Is
>this ok to do?
Yes; this is what you typically do when you want to connect from
a certain port/range of ports.
>Most books I read have the steps for server as
>socket->bind->listen->accept->recv->send->close and for client its
>socket->connect->send->recv->close. I want my client bound to a known port,
>because later I need some other process to connect to my client which brings
>me to my second question - on the client side once I do
>socket->bind->connect, now how do I close this connection? I do not want to
>do close() because later in the client I want to be able to listen to
>incoming requests on the port that I have just bound the client socket to.
You can't; you need to make a new socket for that. stream sockets cannot
be reused as endpoints.
>Also, what is the effect of executing a recv() call expecting more bytes
>than have been send(). For example if A sends B 10 bytes and B does a recv()
>for 30 bytes, whats going to happen at B - What is the default behaviour in
>this case? Will it block? Will it just read the 10 bytes and proceed?
It will read 10 bytes. Note that since you use tcp, 2 10 byte messages may show
up as one 20 byte message (or a 15 and 5 byte message)
Casper
--
Expressed in this posting are my opinions. They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.
|
|
0
|
|
|
|
Reply
|
Casper
|
10/4/2004 8:51:09 AM
|
|
|
1 Replies
401 Views
(page loaded in 0.046 seconds)
Similiar Articles: bind() and connect() issues [Newbie] - comp.unix.solaris ...Hi, I have a client which executes a bind() call before a connect() call. Is this ok to do? Most books I read have the steps for server as socket-... Connection refused problem - comp.unix.programmerbind() and connect() issues [Newbie] - comp.unix.solaris ..... my config and zone files to refresh by restarting bind ... If you have any problems with the registration ... Bind to port 22 on 0.0.0.0 failed: Address already in use - comp ...bind() and connect() issues [Newbie] - comp.unix.solaris ..... on 0.0.0.0 failed: Address already in use - comp ... bind() and connect() issues [Newbie] - comp.unix ... connect() failed: Connection refused (111) - comp.parallel.mpi ...bind() and connect() issues [Newbie] - comp.unix.solaris ..... to port 22 on 0.0.0.0 failed: Address already in use - comp ... bind() and connect() issues [Newbie ... Book Port - comp.sys.mac.appsbind() and connect() issues [Newbie] - comp.unix.solaris ... Yes; this is what you typically do when you want to connect from a certain port/range of ports. >Most books I ... Windows server, Unix client, connection refused on client connect ...bind() and connect() issues [Newbie] - comp.unix.solaris ..... the client side once I do socket->bind->connect, now how do I close this connection? ... comp.unix.solaris ... 1 Port, listening and connecting, how to? - comp.unix.programmer ...bind() and connect() issues [Newbie] - comp.unix.solaris ... 1 Port, listening and connecting, how to? - comp.unix.programmer ... bind() and connect() issues [Newbie ... connect NONBLOCK and select - comp.unix.solarisbind() and connect() issues [Newbie] - comp.unix.solaris ... Let us no forget, the thread safety issues with signal. ... Unix Systems Programming Newbie - exec format ... UDP Broadcast problem - comp.lang.c++port listen/send - comp.lang.javascript bind() and connect() issues [Newbie] - comp.unix.solaris ..... you typically do ... C# UDP Broadcast Send And Receive I am also ... rpc-bind error - comp.sys.sun.adminbind() and connect() issues [Newbie] - comp.unix.solaris ... rpc-bind error - comp.sys.sun.admin... My main question is how do I resolve rpc-bind ... netdir_getbyname for ... bind() and connect() issues [Newbie] - comp.unix.solaris ...Hi, I have a client which executes a bind() call before a connect() call. Is this ok to do? Most books I read have the steps for server as socket-... vsftpd vsf_sysutil_bind problem... Linux - Networking: vsftpd vsf_sysutil_bind problem ... I can get users to connect etc, but when browsing the ... LQ Newbie 7/21/2012 2:53:44 AM
|
|
|
|
|
|
|
|
|