Created
January 28, 2020 14:13
-
-
Save RootTJNII/0c108b716cdd826dd1e6917b92c72090 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <netdb.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <unistd.h> | |
#include <sys/socket.h> | |
#include <netinet/in.h> | |
#include <arpa/inet.h> | |
int main() | |
{ | |
int sockfd, connfd; | |
struct sockaddr_in servaddr, cli; | |
char buf[1460]; | |
sockfd = socket(AF_INET, SOCK_STREAM, 0); | |
if (sockfd == -1) { | |
printf("socket creation failed...\n"); | |
return 1; | |
} | |
printf("Socket successfully created..\n"); | |
memset(&servaddr, 0, sizeof(servaddr)); | |
servaddr.sin_family = AF_INET; | |
servaddr.sin_addr.s_addr = inet_addr("127.0.0.1"); | |
servaddr.sin_port = htons(4321); | |
// connect the client socket to server socket | |
if (connect(sockfd, (struct sockaddr*)&servaddr, sizeof(servaddr)) != 0) { | |
printf("connection with the server failed...\n"); | |
return 1; | |
} | |
printf("connected to the server..\n"); | |
read(sockfd, buf, sizeof(buf)); | |
printf("From Server : %s", buf); | |
close(sockfd); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM debian:stretch | |
RUN apt-get update && apt-get install -y git python libxml2 | |
RUN git clone https://github.com/emscripten-core/emsdk.git && \ | |
cd emsdk && \ | |
./emsdk install latest && \ | |
./emsdk activate latest | |
ENV PATH="/emsdk:/emsdk/node/12.9.1_64bit/bin:/emsdk/upstream/emscripten:${PATH}" | |
COPY files/src /src | |
WORKDIR src | |
RUN emcc connection_test.c -o connection_test.html | |
CMD emrun --no_browser --port 8080 . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GET / HTTP/1.1 | |
Host: 127.0.0.1:4321 | |
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:72.0) Gecko/20100101 Firefox/72.0 | |
Accept: */* | |
Accept-Language: en-US,en;q=0.5 | |
Accept-Encoding: gzip, deflate | |
Sec-WebSocket-Version: 13 | |
Origin: http://10.6.0.159:8080 | |
Sec-WebSocket-Protocol: binary | |
Sec-WebSocket-Extensions: permessage-deflate | |
Sec-WebSocket-Key: eQ1PRC4mT6pLSizRjTKlmA== | |
DNT: 1 | |
Connection: keep-alive, Upgrade | |
Pragma: no-cache | |
Cache-Control: no-cache | |
Upgrade: websocket |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment