Unix Programming - Read/Write socket Problem

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > May 2005 > Read/Write socket Problem





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Read/Write socket Problem
Xarky

2005-05-05, 2:51 am

Hi,

My getline() method is below. I am using sockets;

void getline(char s[], int lim)
{
int c, i;

for (i=0; ((i<lim-1) && ((c=getchar()) != '\n')); i++)
s[i] = c;

s[i] = '\0';
}

The problem is that if I send data of 1 character(example 1), the
server replies with a 'G' with no problem. But if I send 9, and the
number randomized is smaller, problem described is occuring.
Barry Margolin

2005-05-05, 8:48 pm

In article <bc42e1a.0505042254.15421d8@posting.google.com>,
bernardpace@yahoo.com (Xarky) wrote:

> Hi,
>
> My getline() method is below. I am using sockets;
>
> void getline(char s[], int lim)
> {
> int c, i;
>
> for (i=0; ((i<lim-1) && ((c=getchar()) != '\n')); i++)
> s[i] = c;
>
> s[i] = '\0';
> }
>
> The problem is that if I send data of 1 character(example 1), the
> server replies with a 'G' with no problem. But if I send 9, and the
> number randomized is smaller, problem described is occuring.


There seems to be some context missing in this post. I suspect you're
following up to another thread, so you should post this message in that
thread. All by itself it makes absolutely no sense.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com