
Enviado em 25/10/2018 - 21:52h
Olá, boa noite a todos!
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <netdb.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netinet/in.h>
#define PORT "9009"
int make_server_socket(void){
int sockfd;
struct addrinfo *res=NULL, hints;
memset(&hints, 0, sizeof(hints));
hints.ai_flags=AI_PASSIVE;
hints.ai_family=AF_UNSPEC;
hints.ai_socktype=SOCK_STREAM;
hints.ai_protocol=IPPROTO_TCP;
if(getaddrinfo(NULL, PORT, &hints, &res)!=0){
sockfd=-1;
}else{
if((sockfd=socket(res->ai_family, SOCK_STREAM, IPPROTO_TCP))!=-1){
if(bind(sockfd, res->ai_addr, res->ai_addrlen)<0){
sockfd=-1;
}
}
freeaddrinfo(res);
}
return sockfd;
}
int main(void){
int sockfd=make_server_socket();
if(sockfd!=-1){
listen(sockfd, 1);
int csockfd=accept(sockfd, NULL, NULL);
if(csockfd!=-1){
send(csockfd, "Real Muthaphuckkin G's", 23, 0);
}
close(sockfd);
close(csockfd);
}
return 0;
}
zherkezhi@zherkezhi :~/Documents/C/Perguntas$ nc -4 127.0.0.1 9009
Real Muthaphuckkin G's
zherkezhi@zherkezhi:~/Documents/C/Perguntas$ #Funcionou perfeitamente!
zherkezhi@zherkezhi:~/Documents/C/Perguntas$ nc -6 ::1 9009
zherkezhi@zherkezhi:~/Documents/C/Perguntas$ #não aconteceu nada *_*
Monitorando o Preço do Bitcoin ou sua Cripto Favorita em Tempo Real com um Widget Flutuante
IA Turbina o Desktop Linux enquanto distros renovam forças
Como extrair chaves TOTP 2FA a partir de QRCODE (Google Authenticator)
Ativando e usando "zoom" no ambiente Cinnamon
Vídeo Nostálgico de Instalação do Conectiva Linux 9
Como realizar um ataque de força bruta para desobrir senhas?
Eu queria adicionar a incon do wifi e deixa transparente no fluxbox no... (4)
Thinkpads são bons mesmo ?! (4)
existe algum hub de jogos online similiar ou igual dos browser (6)
Como botar o efeito de deslocar janelas (win + setas - windows) no lin... (0)









