C# Raw Socket Issues starting TCP Connections

From: banduraj (banduraj_at_dtmf.org)
Date: 03/17/05


Date: 17 Mar 2005 07:12:20 -0800

I am working on starting and managing TCP connections manually. I build
the IP headers and TCP packets manually and send them on my own. The
problems I run into seems to be related to the Sockets. Maybe someone
can help me out.

1) I can build the packets and put them out fine, however, I can only
read incomming data if I use IOControl and set the socket SIO_RCVALL.
But doing this seems to apply to other sockets I maybe running in a
diffrent thread.

2) The biggest problem I have seems to be starting a TCP connection. If
I send a SYN, I get a SYN/ACK or SYN/RST like I am suppose to, but for
some reason the Socket replys with a RST with out me doing anything.

Here is how I am building the socket and sending the data...

Socket remote = new Socket(AddressFamily.InterNetwork, SocketType.Raw,
ProtocolType.IP);
remote.Bind(this.l_ipep);
remote.SetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.ReceiveTimeout, this.timeout_time);
remote.SetSocketOption(SocketOptionLevel.IP,
SocketOptionName.HeaderIncluded, 1);
int ret = remote.IOControl(SIO_RCVALL, oin, oout);

if (BitConverter.ToInt32(oout, 0) != 0) {
return error;
}

...

this.remote.SendTo(ip_packet.get_packet(), this.r_ipep);

What am I doing wrong??? Why does the socket send a RST without me
doing anything? Why can't I read data without setting the socket in
promiscious mode. And why is it that when I do set the socket to
promiscious mode that it seems to apply to other sockets running in
diffrent threads? Thanks.



Relevant Pages

  • Re: how to use wait_event_interruptible_timeout
    ... I have a kernel module where I have ... opened multiple tcp connections. ... i want my process to sleep. ... so that whenever data is available on any socket (tcp ...
    (Linux-Kernel)
  • Re: kernel panic: page fault
    ... It looks like we have an inconsistency in how we handle the recycling of timewait state for an inpcb that is still present. ... the problem is how to handle sockets with attached inpcbs that represent closed or time wait TCP connections. ... This can happen if shutdownis called on a socket, kicking the TCP state engine into a close cycle, rather than a reset. ... This is related to the inpcb without twtcp case, where we recycle the twtcp, but can't recylce the inpcb immediately because there's still an fd reference to the socket, and hence a socket reference to the inpcb. ...
    (freebsd-current)
  • [6.x] problem with AIO, non-blocking sockets on freebSD and IE7 on windows.
    ... If one has an event-driven process that accepts tcp connections, one needs to set eh non-blocking socket option and use kqueue or similar to schedule work. ... to tell it to put the session in question onto a timer.. ...
    (freebsd-net)
  • Re: My server sometimes goes deaf to certain hosts
    ... If your program is blocked on a pipe or unix socket, ... new TCP connections because it won't call 'accept' until the blocking ... so you are saying that the listening process might be blocking ...
    (comp.os.linux.development.apps)
  • RE: help: raw_ip socket and system implication
    ... Subject: help: raw_ip socket and system implication ... The RST is coming from your own stack, which is not aware of the ...
    (Vuln-Dev)