Functions in socket
- From: "nick048" <nicosia.gaetano@xxxxxxxxxxx>
- Date: 31 Mar 2007 00:06:50 -0700
Hi to all,
I need to write a little server that attend on port example 10000.
I have write the code of the server and tested it. It work fine.
Now, I need to pass from a client (example telnet) a phrase
(multiline) terminated by "..".
In the main my code is:
listen(sock, 1);
/* connection from client */
while (1) {
client_len = sizeof(client);
if ((fd = accept(sock, (struct sockaddr *)&client, &client_len)) < 0)
{
perror("accepting connection");
exit(3);
}
fprintf(stderr, "Connection open.\n");
send(fd, "Wellcome in my Server!\n\n", 38, 0);
send(fd, "Send to me a Phrase (close send with ..)!\n\n", 44, 0);
receive_phrase(fd, fd);
close(fd);
fprintf(stderr, "Connection closed.\n");
}
Can You suggest me how create the function receive_phrase terminated
with "..".
I hope in Your help.
Best Regards
Gaetano
.
- Follow-Ups:
- Re: Functions in socket
- From: Cong Wang
- Re: Functions in socket
- From: Ulrich Eckhardt
- Re: Functions in socket
- Prev by Date: Re: Is it a good thing that program mix C and C++?
- Next by Date: Re: Functions in socket
- Previous by thread: Restrict qualified pointers in C
- Next by thread: Re: Functions in socket
- Index(es):
Relevant Pages
|