projects
/
gapil.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Rinominate le prime versioni dei vari programmi in Elem, la versione piu`
[gapil.git]
/
sources
/
SimpleEchoTCPServer.c
diff --git
a/sources/SimpleEchoTCPServer.c
b/sources/SimpleEchoTCPServer.c
index 35a2737cc061cecaa644c1a7dc539e2e07156943..9611e365eb2856d3e75f9de0c019c80a8896a1d9 100644
(file)
--- a/
sources/SimpleEchoTCPServer.c
+++ b/
sources/SimpleEchoTCPServer.c
@@
-8,7
+8,7
@@
*
* Usage: echod
*
*
* Usage: echod
*
- * $Id: SimpleEchoTCPServer.c,v 1.
1 2001/06/10 11:47:17
piccardi Exp $
+ * $Id: SimpleEchoTCPServer.c,v 1.
3 2001/06/12 22:17:22
piccardi Exp $
*
****************************************************************/
/*
*
****************************************************************/
/*
@@
-26,11
+26,10
@@
#define BACKLOG 10
#define MAXLINE 256
#define BACKLOG 10
#define MAXLINE 256
-/* Subroutine declaration */
+/* Subroutine
s
declaration */
void usage(void);
void SockEcho(int sockfd);
void usage(void);
void SockEcho(int sockfd);
-
-/* Program begining */
+/* Program beginning */
int main(int argc, char *argv[])
{
/*
int main(int argc, char *argv[])
{
/*
@@
-77,7
+76,7
@@
int main(int argc, char *argv[])
/* initialize address */
memset((void *)&serv_add, 0, sizeof(serv_add)); /* clear server address */
serv_add.sin_family = AF_INET; /* address type is INET */
/* initialize address */
memset((void *)&serv_add, 0, sizeof(serv_add)); /* clear server address */
serv_add.sin_family = AF_INET; /* address type is INET */
- serv_add.sin_port = htons(
13); /* daytime port is 13
*/
+ serv_add.sin_port = htons(
7); /* echo port is 7
*/
serv_add.sin_addr.s_addr = htonl(INADDR_ANY); /* connect from anywhere */
/* bind socket */
if (bind(list_fd, (struct sockaddr *)&serv_add, sizeof(serv_add)) < 0) {
serv_add.sin_addr.s_addr = htonl(INADDR_ANY); /* connect from anywhere */
/* bind socket */
if (bind(list_fd, (struct sockaddr *)&serv_add, sizeof(serv_add)) < 0) {
@@
-130,7
+129,8
@@
void SockEcho(int sockfd) {
int nread, nwrite;
/* main loop, reading 0 char means client close connection */
int nread, nwrite;
/* main loop, reading 0 char means client close connection */
- while ( (nread = SockRead(sockfd, buffer, MAXLINE)) != 0) {
+ while ( (nread = read(sockfd, buffer, MAXLINE)) != 0) {
+ printf("Letti %d bytes, %s ", nread, buffer);
nwrite = SockWrite(sockfd, buffer, nread);
}
return;
nwrite = SockWrite(sockfd, buffer, nread);
}
return;