CS计算机代考程序代写 #include

#include
#include
#include
#include
#include
#include
#include
#include

int main(int argc, char *argv[]){
char buffer[100] = “Hello, here is my message\n”;

int sd, client;
socklen_t len;

struct sockaddr_in servAdd; //server socket address
struct sockaddr_in cliAdd; //client socket address

sd = socket(AF_INET, SOCK_STREAM, 0);

servAdd.sin_family = AF_INET;
servAdd.sin_addr.s_addr = inet_addr(“137.207.82.53”); // or use INADDR_ANY;
//INADDR_ANY allows your program to work without
// knowing the IP address of the machine it was running on

servAdd.sin_port = 7777; // a port number

//all steps above are for calling bind.
bind(sd,(struct sockaddr*)&servAdd,sizeof(servAdd));

listen(sd, 5);

while(1){

len = sizeof(cliAdd);

client=accept(sd,(struct sockaddr*)&cliAdd, &len); //accept (sd, NULL, NULL);

write(client, buffer, strlen(buffer) + 1);

close(client);
break;
}
}