Hi, some thoughts...
* Using PF_INET + SOCK_DGRAM automatically gets you a UDP socket. So it doesn't make sense to use IPPROTO_TCP on it (usually it is wisest to just use zero (0) as the last argument of socket().)
* To make a TCP socket, just use "socket(PF_INET, SOCK_STREAM, 0)". But then, of course, you can no longer see the individual packets, they are then presented as a stream of bytes (just like a file). So you would have to transfer the data like this (first creating input and output sockets, etc. etc.):
Code:
byte buffer[2048];
for(;;)
{
int bytes_read = read(sock_in, buffer, 2048);
if (!bytes_read) break;
write(sock_out, buffer, bytes_read);
}
* SOCK_RAW can give you access to all IP packets but requires root access.
* To get more information on the error when binding the socket, you can use:
Code:
if (bind(...) < 0)
perror("error bind s1");
* A similar thing to what this program does, can also be done in linux with a IPTABLES redirection (but this also requires root access).
Hope this helps,
nukkel