Dsy Network www | forum | my | didattica | howto | wiki | el goog | stats | blog | dona | rappresentanti
Homepage
 Register   Calendar   Members  Faq   Search  Logout 
.dsy:it. : Powered by vBulletin version 2.3.1 .dsy:it. > Community > Forum De Bell Tolls > [FSE P.R. in C] servizio echo HELP
  Last Thread   Next Thread
Author
Thread    Expand all | Contract all    Post New Thread    Post A Reply
Collapse
DeepBlue
tired guy

User info:
Registered: Sep 2003
Posts: 4258 (0.52 al dì)
Location: CSN
Corso: Info tlc
Anno:
Time Online: 52 Days, 8:40:31 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
[FSE P.R. in C] servizio echo HELP

ok, mi arrendo. Non mi funziona e non capisco perché.

Ho riscritto il programma a casa, attivato il servizio echo e nonostante tutto non riesco a trasmettere sto benedetto messaggio.
La socket viene creata, la connessione avviene, apparentemente avviene anche la trasmissione, ma a terminale non mi appare niente :(
Qualcuno mi sa dare una dritta?

Ecco il codice:

code:
#include <stdio.h> #include <netinet/in.h> #include <sys/types.h> #include <sys/socket.h> int main (void){ struct sockaddr_in server_addr; int sd; char *message = "hello world"; sd = socket (AF_INET, SOCK_STREAM, 0); if (sd < 0) { perror("socket() "); exit(1); } printf("Socket creata\n"); server_addr.sin_family = AF_INET; server_addr.sin_addr.s_addr = inet_addr("127.0.0.1"); server_addr.sin_port = htons(7); if ( connect(sd, &server_addr, sizeof(server_addr)) != 0) { perror("connect() "); exit(1); } printf("Connesso...\n"); printf("Inviati %d byte\n", write(sd, message,strlen(message))); close(sd); printf("programma terminato\n\n"); return 0; }

__________________
~ get Debian! ~ get FreeBSD! ~ get OpenBSD! ~

08-05-2004 13:23
Click Here to See the Profile for DeepBlue Click Here to See the Blog of DeepBlue Click here to Send DeepBlue a Private Message Find more posts by DeepBlue Add DeepBlue to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Flyzone
.coltellino:svizzero.

User info:
Registered: Jan 2003
Posts: 1956 (0.23 al dì)
Location:
Corso:
Anno:
Time Online: 19 Days, 22:20:19 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
Re: [FSE P.R. in C] servizio echo HELP

Originally posted by DeepBlue
ok, mi arrendo. Non mi funziona e non capisco perché.

Ho riscritto il programma a casa, attivato il servizio echo e

Non stò seguendo l'fse quindi non sò esattamente quello che stai facendo...
Cmq il codice che hai postato con il mio echo server funziona, la connessione avviene ed il testo viene inviato...a parte che non invi un \n ma quello dipende da quello che vuoi far tu.
Che server echo utilizzi?

08-05-2004 16:16
Click Here to See the Profile for Flyzone Click Here to See the Blog of Flyzone Click here to Send Flyzone a Private Message Find more posts by Flyzone Add Flyzone to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
DeepBlue
tired guy

User info:
Registered: Sep 2003
Posts: 4258 (0.52 al dì)
Location: CSN
Corso: Info tlc
Anno:
Time Online: 52 Days, 8:40:31 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Ma porc... Sto usando quello di Linux (su TCP), forse non l'ho attivato bene.

Quello che non capisco è come mai nemmeno ieri in SiLAB funzionasse: controllato tre volte che il conf fosse settato correttamente e l'ho riavviato due volte... Boh... vedo di capire perché qui non funziona, se lo scopro riposto.

Grazie :)

__________________
~ get Debian! ~ get FreeBSD! ~ get OpenBSD! ~

08-05-2004 16:59
Click Here to See the Profile for DeepBlue Click Here to See the Blog of DeepBlue Click here to Send DeepBlue a Private Message Find more posts by DeepBlue Add DeepBlue to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
lord2y
BANNATO

User info:
Registered: Jul 2002
Posts: 1498 (0.17 al dì)
Location: Milano
Corso: Qualcosa a che fare con l'informatica
Anno: 24esimo ;-(
Time Online: 9 Days, 17:16:35 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

non funziona perchè scrivi sulla socket ma non leggi.

manca la read nel tuo codice ;)

code:
printf("Connesso...\n"); printf("Inviati %d byte\n", write(sd, message,strlen(message))); /*Io farei*/ nbyte_w = write(sd, message, sizeof(message)); read(sd, message2, nbyte_w); printf("%s", message2); close(sd); printf("programma terminato\n\n"); return 0; }



In ogni caso dovrebbe funzionare...

ricordo che l'echo è avviato da inetd o xinetd.
Guarda di aver avviato il deamon con

code:
#/etc/init.d/inetd start oppure #/etc/init.d/xinetd start


:ciao:

__________________
Linux User#271051
Only God can judge me, is that right?
Only God can judge me now
Only God baby, nobody else. All you other motherfuckers get out my business (2Pac)

Last edited by lord2y on 08-05-2004 at 17:33

08-05-2004 17:11
Click Here to See the Profile for lord2y Click Here to See the Blog of lord2y Click here to Send lord2y a Private Message Visit lord2y's homepage! Find more posts by lord2y Add lord2y to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
DeepBlue
tired guy

User info:
Registered: Sep 2003
Posts: 4258 (0.52 al dì)
Location: CSN
Corso: Info tlc
Anno:
Time Online: 52 Days, 8:40:31 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by lord2y
non funziona perchè scrivi sulla socket ma non leggi.

manca la read nel tuo codice ;)

*imprecazioni varie*

Non avevo capito che servisse la read..che pirla! In effetti è logico che serva...
Mi mangerò le mani per il resto della serata :)

Fly ma tu sotto cosa hai compilato che ti funzia?

Grazie a tutti cmq :)
lord2y ci vediamo lunedì :P

__________________
~ get Debian! ~ get FreeBSD! ~ get OpenBSD! ~

08-05-2004 17:46
Click Here to See the Profile for DeepBlue Click Here to See the Blog of DeepBlue Click here to Send DeepBlue a Private Message Find more posts by DeepBlue Add DeepBlue to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
lord2y
BANNATO

User info:
Registered: Jul 2002
Posts: 1498 (0.17 al dì)
Location: Milano
Corso: Qualcosa a che fare con l'informatica
Anno: 24esimo ;-(
Time Online: 9 Days, 17:16:35 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by DeepBlue
*imprecazioni varie*

Non avevo capito che servisse la read..che pirla! In effetti è logico che serva...
Mi mangerò le mani per il resto della serata :)

Fly ma tu sotto cosa hai compilato che ti funzia?

Grazie a tutti cmq :)
lord2y ci vediamo lunedì :P


ok, buona domenica ;)
:ciao:

__________________
Linux User#271051
Only God can judge me, is that right?
Only God can judge me now
Only God baby, nobody else. All you other motherfuckers get out my business (2Pac)

08-05-2004 17:48
Click Here to See the Profile for lord2y Click Here to See the Blog of lord2y Click here to Send lord2y a Private Message Visit lord2y's homepage! Find more posts by lord2y Add lord2y to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Flyzone
.coltellino:svizzero.

User info:
Registered: Jan 2003
Posts: 1956 (0.23 al dì)
Location:
Corso:
Anno:
Time Online: 19 Days, 22:20:19 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by DeepBlue
Fly ma tu sotto cosa hai compilato che ti funzia?

:asd: a me funzionava la scrittura, pensavo che avessi un server echo tuo che stampava nella schermata da dove lo lanciavi (come il mio serverino echo multiuso) ecco perchè non avevo considerato la read! :oops: chiedo scusa :oops:

P.S: ok ammetto che in tutta la mia vita i servizi echo li ho dovuti sempre disattivare mai attivare :D

08-05-2004 19:48
Click Here to See the Profile for Flyzone Click Here to See the Blog of Flyzone Click here to Send Flyzone a Private Message Find more posts by Flyzone Add Flyzone to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
DeepBlue
tired guy

User info:
Registered: Sep 2003
Posts: 4258 (0.52 al dì)
Location: CSN
Corso: Info tlc
Anno:
Time Online: 52 Days, 8:40:31 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Off-Topic:
se qualcuno ha avuto problemi con le bcopy (deference to an incomplete type)) puo` aggiungere l'header file netdb.h.

Sicuramente il problema si risolve :)

__________________
~ get Debian! ~ get FreeBSD! ~ get OpenBSD! ~

10-05-2004 17:45
Click Here to See the Profile for DeepBlue Click Here to See the Blog of DeepBlue Click here to Send DeepBlue a Private Message Find more posts by DeepBlue Add DeepBlue to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
All times are GMT. The time now is 18:47.    Post New Thread    Post A Reply
  Last Thread   Next Thread
Show Printable Version | Email this Page | Subscribe to this Thread | Add to Bookmarks

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is ON
 

Powered by: vBulletin v2.3.1 - Copyright ©2000 - 2002, Jelsoft Enterprises Limited
Mantained by dsy crew (email) | Collabora con noi | Segnalaci un bug | Archive | Regolamento | Licenze | Thanks | Syndacate
Pagina generata in 0.105 seconds (31.83% PHP - 68.17% MySQL) con 25 query.