49 lines
1.1 KiB
C
49 lines
1.1 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <unistd.h>
|
|
#include <netinet/in.h>
|
|
#include <sys/types.h>
|
|
#include <sys/socket.h>
|
|
#include <arpa/inet.h>
|
|
#include <netdb.h>
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
struct sockaddr_in myaddr, endpoint;
|
|
int sdsocket, sdconnection, addrlen, received;
|
|
const int port = 7332;
|
|
|
|
sdsocket = socket(AF_INET, SOCK_STREAM, 0);
|
|
addrlen = sizeof(struct sockaddr_in);
|
|
|
|
myaddr.sin_family = AF_INET;
|
|
myaddr.sin_port = htons(port);
|
|
myaddr.sin_addr.s_addr = htonl(INADDR_ANY);
|
|
|
|
if (bind(sdsocket, (struct sockaddr *)&myaddr, addrlen) < 0)
|
|
{
|
|
printf("bind() nie powiodl sie (failed)\n");
|
|
return 1;
|
|
}
|
|
|
|
if (listen(sdsocket, 10) < 0)
|
|
{
|
|
printf("listen() nie powiodl sie (failed)\n");
|
|
return 1;
|
|
}
|
|
|
|
while ((sdconnection =
|
|
accept(sdsocket,
|
|
(struct sockaddr *)&endpoint,
|
|
&addrlen)) >= 0)
|
|
{
|
|
|
|
send(sdconnection, "CONNECT", 7, 0);
|
|
close(sdconnection);
|
|
}
|
|
|
|
close(sdsocket);
|
|
return 0;
|
|
}
|