|
|
|
|
||||||
| comp.protocols.tcp-ip TCP and IP network protocols. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hello,
In a socket based program,is it possible to know, when returning from listening to whom we will be connected before issueing the accept s= socket(xxx) bind(xxx) listen(xxxx) Can we know here to whom we will be connected (ip address of peer) accept(xxx) Thank you Aron |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
awahl@yahoo.com writes:
> In a socket based program,is it possible to know, when returning from > listening to whom we will be connected before issueing the accept > > s= socket(xxx) > bind(xxx) > listen(xxxx) > > Can we know here to whom we will be connected (ip address of peer) > > accept(xxx) No. It sounds like what you _might_ want is something that's sometimes called "lazy accept" -- the ability to look at inbound TCP SYN messages and decide which ones you want to reply to, rather than having the stack itself manage SYN-ACK. I don't know of any modern OS that does this, and unless your application is in the kernel (and in fact part of TCP itself), there's a serious denial-of-service risk associated with it. If what you're looking for is actually just a "peek" mode on accept, what would you do if you had this? (Is this an inetd "nowait" service but with libwrap?) -- James Carlson, KISS Network <james.d.carlson@sun.com> Sun Microsystems / 1 Network Drive 71.232W Vox +1 781 442 2084 MS UBUR02-212 / Burlington MA 01803-2757 42.496N Fax +1 781 442 1677 |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On Tue, 21 Nov 2006 11:33:01 -0500, James Carlson wrote:
> awahl@yahoo.com writes: >> In a socket based program,is it possible to know, when returning from >> listening to whom we will be connected before issueing the accept >> >> s= socket(xxx) >> bind(xxx) >> listen(xxxx) >> >> Can we know here to whom we will be connected (ip address of peer) >> >> accept(xxx) > > No. > > It sounds like what you _might_ want is something that's sometimes > called "lazy accept" -- the ability to look at inbound TCP SYN > messages and decide which ones you want to reply to, rather than > having the stack itself manage SYN-ACK. I don't know of any modern OS > that does this, and unless your application is in the kernel (and in > fact part of TCP itself), there's a serious denial-of-service risk > associated with it. On Linux you can write it using netfilter queues. Not that I advocate that, but if you really need that functionality. Or just use tcpwrappers, it may be exactly what the OP wants. M4 -- Redundancy is a great way to introduce more single points of failure. |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
awahl@yahoo.com wrote: > In a socket based program,is it possible to know, when returning from > listening to whom we will be connected before issueing the accept > > s= socket(xxx) > bind(xxx) > listen(xxxx) > > Can we know here to whom we will be connected (ip address of peer) > > accept(xxx) On most TCP/IP stacks, you may be already connected. So the question doesn't make sense. DS |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
Ok thanks to all,
The only think I wanted to know if it was possible to do it within the socket framework. Apparently it is not. Too bad. Aron David Schwartz wrote: > awahl@yahoo.com wrote: > > > In a socket based program,is it possible to know, when returning from > > listening to whom we will be connected before issueing the accept > > > > s= socket(xxx) > > bind(xxx) > > listen(xxxx) > > > > Can we know here to whom we will be connected (ip address of peer) > > > > accept(xxx) > > On most TCP/IP stacks, you may be already connected. So the question > doesn't make sense. > > DS |
|
![]() |
| Outils de la discussion | |
|
|