Skip to content

Instantly share code, notes, and snippets.

@Glavak
Created January 16, 2018 13:19
Show Gist options
  • Save Glavak/6b0d3ab953015ff31d3e8cd1b84bb3df to your computer and use it in GitHub Desktop.
Save Glavak/6b0d3ab953015ff31d3e8cd1b84bb3df to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <sys/socket.h>
#include <stdlib.h>
#include <netinet/in.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <poll.h>
#include <errno.h>
int main(int argc, const char * argv[])
{
struct sockaddr_in result;
result.sin_family = AF_INET;
result.sin_port = htons(4242);
inet_pton(AF_INET, "127.0.0.1", &result.sin_addr);
int connectedSocket= socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0);
connect(connectedSocket, (struct sockaddr *) &result, sizeof(result));
sleep(1);
shutdown(connectedSocket, SHUT_WR);
//ssize_t a = read(connectedSocket, NULL, 100);
int a = write(connectedSocket, &connectedSocket, 1);
printf("%d\n", a);
perror("asd");
getchar();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment