/test_bind.c (ef564034e516db96e7e9346000e4a7917da3b82d) (1135 bytes) (mode 100644) (type blob)
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <arpa/inet.h>
int main(int argc, char *argv[])
{
int sock, err;
struct sockaddr_in sa, sa2;
socklen_t sa_len;
int port = 4444;
char junk[128];
unsigned char tos;
sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock == -1) {
perror("socket");
return 1;
}
if (argc >= 2)
port = strtol(argv[1], NULL, 10);
memset(&sa, 0, sizeof(struct sockaddr));
sa.sin_family = AF_INET;
sa.sin_port = htons(port);
sa.sin_addr.s_addr = htonl(INADDR_ANY);
sa_len = sizeof(struct sockaddr_in);
err = bind(sock, (struct sockaddr *) &sa, sa_len);
if (err != 0) {
perror("bind");
return 1;
}
err = getsockname(sock, (struct sockaddr *) &sa2, &sa_len);
if (err != 0) {
perror("getsockname");
return 1;
}
fprintf(stderr, "Socket bound to %s/%d.\n",
inet_ntop(sa2.sin_family, &sa2.sin_addr, junk, sa_len),
ntohs(sa2.sin_port));
tos = 0x00;
err = setsockopt(sock, IPPROTO_IP, IP_TOS, &tos, 1);
if (err != 0)
perror("setsockopt");
close(sock);
return 0;
}
Mode |
Type |
Size |
Ref |
File |
100644 |
blob |
62 |
0cd255905c3bcd0cdcc180419e71e4381b699cc3 |
.gitignore |
100644 |
blob |
30 |
d987fa5df957830331139935d517009e2911b0cf |
INSTALL |
100644 |
blob |
35147 |
94a9ed024d3859793618152ea559a168bbcbb5e2 |
LICENSE |
100644 |
blob |
588 |
ce93d8a5bedc82249e2860b9032dcc243cbce55a |
Makefile.in |
100644 |
blob |
2160 |
08bf90acc0b995cc3a68dcfd9d62ab49825eb158 |
README |
100644 |
blob |
387 |
644a84a7230b2979fd6dc5bb4e3b168da59b787c |
TODO |
100755 |
blob |
23 |
d33bb6c4ecdce1390ce1db3c79ea3b93e22ea755 |
configure |
100755 |
blob |
12723 |
62411b6de6bc9d88b550b7c96e140e8ce9015086 |
duilder |
100644 |
blob |
261 |
11bcae688fe61c68a0e1ac8e6694459208cbc2e3 |
duilder.conf |
100644 |
blob |
16468 |
8967a678ed96992e2b05c7be3a8438a8de076235 |
force_bind.c |
100644 |
blob |
822 |
384112a74639d6ce1d0a178f491d7d816c653b77 |
force_bind.spec.in |
100644 |
blob |
1011 |
96ea103d9e9393fc54a3d0ced697d83852be6831 |
send_udp.c |
100755 |
blob |
198 |
69df55fb33fd2f66c8563d40f8e94c4a050d71f0 |
test1.sh |
100755 |
blob |
178 |
2d9a688355eeb88be7ab177ba95952a155c9e217 |
test2.sh |
100755 |
blob |
350 |
711d78469121dce161d13d338b0d281e0e646ef6 |
test_all.sh |
100644 |
blob |
1135 |
ef564034e516db96e7e9346000e4a7917da3b82d |
test_bind.c |
100755 |
blob |
195 |
9a925f22c43376431a2f16f21d91acafd505a36e |
test_bw1.sh |
100755 |
blob |
206 |
6fda45058df90ac8cb14cc4253c1427005334f2b |
test_bw2.sh |
100755 |
blob |
286 |
805a280956a5a00dd52f54a8803efc6776739314 |
test_bw3.sh |
100755 |
blob |
138 |
15e7a1b1bf39128dc737ba3df39498ad91e56044 |
test_ka1.sh |
100755 |
blob |
136 |
2f0bf21c57db70f4a61e1b4337f41a3c548d099b |
test_mss1.sh |
100755 |
blob |
144 |
e9620dd6d54a12e3582d38ca4fb74861fa540b88 |
test_tos1.sh |
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"
Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/catalinux/force_bind
Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/catalinux/force_bind
Clone this repository using git:
git clone git://git.rocketgit.com/user/catalinux/force_bind
You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a
merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main