C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

problems reading 0 byte from a socket and writing it to a fi

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (French)
View previous topic :: View next topic  
Author Message
Stanislas
Guest





PostPosted: Mon Mar 28, 2005 2:18 pm    Post subject: problems reading 0 byte from a socket and writing it to a fi Reply with quote



hello when i receive the 0 byte from the network my program stops...
could you help me please. here is parts of my code :

:--------------main function ----------------------:

ofstream * writepersist = new ofstream
((userpath+newid).c_str(),ios::out|ios::app|ios::binary);

int size = 0;
char c;
while((int)(c=getchar(s))!=0)
{
writepersist->put(c);
size++;
}

:----------------getchar implementation--------------:


char netaction::getchar(int s)
{
char c;
int error=0;
int err;
while(1)
{
getsockopt(s,SOL_SOCKET,SO_ERROR,(char*)&err,(unsigned
int*)sizeof(err));
if(read(s,&c,1)==1) break;
if(errno!=0) {error = 1; break; }
}
if(error==1)
{
shutdown(s,2);
close(s);
exit(0);
}
return c;
}


:--------------------------:


thank you for your help
Back to top
Stanislas
Guest





PostPosted: Mon Mar 28, 2005 10:08 pm    Post subject: Re: problems reading 0 byte from a socket and writing it to Reply with quote



désolé d'avoir écrit en anglais...

lorsque je lis 0 caractère oui c'est pas initialisé mais je n'essaye
pas de l'utiliser... mon problème arrive quand je recois la valeur 0
que j'ai envoyé depuis un client

[email]polustanislas (AT) hotmail (DOT) com[/email] (Stanislas) wrote in message news:<744a1eb5.0503280618.2ffce43f (AT) posting (DOT) google.com>...
Quote:
hello when i receive the 0 byte from the network my program stops...
could you help me please. here is parts of my code :

:--------------main function ----------------------:

ofstream * writepersist = new ofstream
((userpath+newid).c_str(),ios::out|ios::app|ios::binary);

int size = 0;
char c;
while((int)(c=getchar(s))!=0)
{
writepersist->put(c);
size++;
}

:----------------getchar implementation--------------:


char netaction::getchar(int s)
{
char c;
int error=0;
int err;
while(1)
{
getsockopt(s,SOL_SOCKET,SO_ERROR,(char*)&err,(unsigned
int*)sizeof(err));
if(read(s,&c,1)==1) break;
if(errno!=0) {error = 1; break; }
}
if(error==1)
{
shutdown(s,2);
close(s);
exit(0);
}
return c;
}


:--------------------------:


thank you for your help

Back to top
Ahmed MOHAMED ALI
Guest





PostPosted: Mon Mar 28, 2005 11:42 pm    Post subject: Re: problems reading 0 byte from a socket and writing it to Reply with quote



Bonjour,


Quote:
char c;
if(read(s,&c,1)==1) break;
....

return c;
Vous lisez 1 char.Lorsque vous recevez 0 char.Que contient c ? Il n'est pas
initialisé.

Vous aurez de meilleures réponses si vous posez votre question sur un news
groupe qui traite de la programation réseau.

Ahmed

"Stanislas" <polustanislas (AT) hotmail (DOT) com> wrote

Quote:
hello when i receive the 0 byte from the network my program stops...
could you help me please. here is parts of my code :

:--------------main function ----------------------:

ofstream * writepersist = new ofstream
((userpath+newid).c_str(),ios::out|ios::app|ios::binary);

int size = 0;
char c;
while((int)(c=getchar(s))!=0)
{
writepersist->put(c);
size++;
}

:----------------getchar implementation--------------:


char netaction::getchar(int s)
{
char c;
int error=0;
int err;
while(1)
{
getsockopt(s,SOL_SOCKET,SO_ERROR,(char*)&err,(unsigned
int*)sizeof(err));
if(read(s,&c,1)==1) break;
if(errno!=0) {error = 1; break; }
}
if(error==1)
{
shutdown(s,2);
close(s);
exit(0);
}
return c;
}


:--------------------------:


thank you for your help



Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (French) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.