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(AddressF amily.InterNetw ork, SocketType.Raw,
ProtocolType.IP );
remote.Bind(thi s.l_ipep);
remote.SetSocke tOption(SocketO ptionLevel.Sock et,
SocketOptionNam e.ReceiveTimeou t, this.timeout_ti me);
remote.SetSocke tOption(SocketO ptionLevel.IP,
SocketOptionNam e.HeaderInclude d, 1);
int ret = remote.IOContro l(SIO_RCVALL, oin, oout);
if (BitConverter.T oInt32(oout, 0) != 0) {
return error;
}
....
this.remote.Sen dTo(ip_packet.g et_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.