Page MenuHomeFreeBSD

michaels_stuck_tcp.c

Authored By
rrs
May 13 2020, 3:18 PM
Size
870 B
Referenced Files
None
Subscribers
None

michaels_stuck_tcp.c

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
int
main(void)
{
struct sockaddr_in addr;
const char c = 'A';
const int on = 1;
int fd;
if ((fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
perror("socket");
}
memset(&addr, 0, sizeof(struct sockaddr_in));
addr.sin_family = AF_INET;
addr.sin_len = sizeof(struct sockaddr_in);
addr.sin_port = htons(80);
addr.sin_addr.s_addr = inet_addr("0.0.0.9");
if (setsockopt(3, IPPROTO_TCP, TCP_FASTOPEN, (const void *)&on, (socklen_t)sizeof(int)) != 0) {
perror("setsockopt");
}
if (sendto(fd, &c, sizeof(char), 0, (const struct sockaddr *)&addr, (socklen_t)sizeof(struct sockaddr_in)) < 0) {
perror("sendto");
}
if (close(fd) < 0) {
perror("close");
}
return (0);
}

File Metadata

Mime Type
text/x-c
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2574271
Default Alt Text
michaels_stuck_tcp.c (870 B)

Event Timeline