projects
/
gapil.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Spostato il vecchi myhost.c e creato nuovo programma mygetaddr per provare
[gapil.git]
/
listati
/
UDP_ClientEcho.c
diff --git
a/listati/UDP_ClientEcho.c
b/listati/UDP_ClientEcho.c
index 746d5a772a3e3de7ab73213569556ec285b0be91..24bc6d6e47bbdcc02ca2edc736402820ec190554 100644
(file)
--- a/
listati/UDP_ClientEcho.c
+++ b/
listati/UDP_ClientEcho.c
@@
-1,4
+1,4
@@
-void ClientEcho(FILE * filein, int socket
, struct sockaddr_in * serv_addr
)
+void ClientEcho(FILE * filein, int socket)
{
char sendbuff[MAXLINE+1], recvbuff[MAXLINE+1];
int nread, nwrite;
{
char sendbuff[MAXLINE+1], recvbuff[MAXLINE+1];
int nread, nwrite;
@@
-7,21
+7,17
@@
void ClientEcho(FILE * filein, int socket, struct sockaddr_in * serv_addr)
if (fgets(sendbuff, MAXLINE, filein) == NULL) {
return; /* if no input just return */
} else { /* else we have to write to socket */
if (fgets(sendbuff, MAXLINE, filein) == NULL) {
return; /* if no input just return */
} else { /* else we have to write to socket */
- nwrite = sendto(socket, sendbuff, strlen(sendbuff), 0,
- (struct sockaddr *) serv_addr, sizeof(*serv_addr));
+ nwrite = write(socket, sendbuff, strlen(sendbuff));
if (nwrite < 0) { /* on error stop */
printf("Errore in scrittura: %s", strerror(errno));
return;
}
}
if (nwrite < 0) { /* on error stop */
printf("Errore in scrittura: %s", strerror(errno));
return;
}
}
- nread = re
cvfrom(socket, recvbuff, strlen(sendbuff), 0, NULL, NULL
);
+ nread = re
ad(socket, recvbuff, strlen(sendbuff)
);
if (nread < 0) { /* error condition, stop client */
printf("Errore in lettura: %s\n", strerror(errno));
return;
}
if (nread < 0) { /* error condition, stop client */
printf("Errore in lettura: %s\n", strerror(errno));
return;
}
- if (nread == 0) { /* server closed connection, stop */
- return;
- }
recvbuff[nread] = 0; /* else read is ok, write on stdout */
if (fputs(recvbuff, stdout) == EOF) {
perror("Errore in scrittura su terminale");
recvbuff[nread] = 0; /* else read is ok, write on stdout */
if (fputs(recvbuff, stdout) == EOF) {
perror("Errore in scrittura su terminale");