Sponsored Content
Full Discussion: read system call
Top Forums Programming read system call Post 31997 by hell666 on Saturday 16th of November 2002 06:11:54 AM
Old 11-16-2002
>When i read 4 bytes from a socket the read function returns 0 value. what does it mean?
Read man pages on read(), the return value section. The return value of read() would be zero, stressing there were no bytes read on that stream.

>How should i know whether a message is available in the socket or not?
You could use select() or poll(), the choice is yours.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

how to differentiate system call from library call

Hi, Ho do I differentiate system call from library call? for example if I am using chmod , how do I find out if it is a system call or library call? Thanks Muru (2 Replies)
Discussion started by: muru
2 Replies

2. Programming

c system call

How the c compiler differentiates the system calls and function calls? (1 Reply)
Discussion started by: rangaswamy
1 Replies

3. Shell Programming and Scripting

system call

Hi, How to write a system calls in a script ? > cd $HOME > ls -ltr thanks in advance.. (10 Replies)
Discussion started by: hegdeshashi
10 Replies

4. Programming

C:system call

Hi I'm studing the system call. I've written a small program that return the time spent in doing some operations. Now I'd like to write one that return the time spent in user mode of a process. I'm reading that i should use the tms struct: clock_t times(struct tms *buf); struct tms {... (2 Replies)
Discussion started by: Dedalus
2 Replies

5. SCO

file system not getting mounted in read write mode after system power failure

After System power get failed File system is not getting mounted in read- write mode (1 Reply)
Discussion started by: gtkpmbpl
1 Replies

6. UNIX for Advanced & Expert Users

Problem in read() system call in Xenomai-2.4

Dear All, I am having problem with read() system call in Blocking Mode. In my driver interrupt intimation done through RT FIFO. so i have created the RT FIFO and open the FIFO using open() system call with O_RDONLY flag and i am waiting for interrupt using read() blocking call.initally... (1 Reply)
Discussion started by: rajamohan
1 Replies

7. UNIX for Advanced & Expert Users

read system call reading the same data

Hi, I wrote a program, to read from a master terminal. However, the 'read' system call keeps returning the same data endlessly (I expected it to read once and then block). What will cause t data to be flushed, after 1 read? #include <stdio.h> #include <string.h> #include <sys/types.h>... (1 Reply)
Discussion started by: karthikb23
1 Replies

8. Programming

system call

I have a cgi script which is called after certain time interval, which has this: system ("ls -l /tmp/cgic* | grep -v \"cgicsave.env\" | awk '{print $5}'"); During the execution of this script,the output is 0 sometimes. But due to this the system call is not working at all and doesnt o/p... (2 Replies)
Discussion started by: xs2punit
2 Replies

9. Programming

need help with system call

hi everyone i wrote a system call and compiled the kernel succesfully... my system call is in a file in the kernel folder named my_syscall1.c (kernel/my_syscall1.c) the header file for this system call i added it in the folder include like this include/my_syscall1/my_syscall1.h my problem is... (2 Replies)
Discussion started by: demis87
2 Replies

10. Shell Programming and Scripting

system call

Trying to figure out a load issue with a webserver. I have traced a php script and noticed the following connect(4, {sa_family=AF_INET, sin_port=htons(3306), sin_addr=inet_addr("XX.XX.XX.XX")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000035> poll(, 1, 2000) = 1 () <0.000120>... (5 Replies)
Discussion started by: rajan007
5 Replies
READ(2) 							System Calls Manual							   READ(2)

NAME
read, readv - read input SYNOPSIS
cc = read(d, buf, nbytes) int cc, d; char *buf; unsigned short nbytes; #include <sys/types.h> #include <sys/uio.h> cc = readv(d, iov, iovcnt) int cc, d; struct iovec *iov; int iovcnt; DESCRIPTION
Read attempts to read nbytes of data from the object referenced by the descriptor d into the buffer pointed to by buf. Readv performs the same action, but scatters the input data into the iovcnt buffers specified by the members of the iov array: iov[0], iov[1], ..., iov[iovcnt-1]. For readv, the iovec structure is defined as struct iovec { caddr_t iov_base; u_short iov_len; }; Each iovec entry specifies the base address and length of an area in memory where data should be placed. Readv will always fill an area completely before proceeding to the next. On objects capable of seeking, the read starts at a position given by the pointer associated with d (see lseek(2)). Upon return from read, the pointer is incremented by the number of bytes actually read. Objects that are not capable of seeking always read from the current position. The value of the pointer associated with such an object is undefined. Upon successful completion, read and readv return the number of bytes actually read and placed in the buffer. The system guarantees to read the number of bytes requested if the descriptor references a normal file that has that many bytes left before the end-of-file, but in no other case. If the returned value is 0, then end-of-file has been reached. RETURN VALUE
If successful, the number of bytes actually read is returned. Otherwise, a -1 is returned and the global variable errno is set to indicate the error. ERRORS
Read and readv will fail if one or more of the following are true: [EBADF] D is not a valid file or socket descriptor open for reading. [EFAULT] Buf points outside the allocated address space. [EIO] An I/O error occurred while reading from the file system. [EINTR] A read from a slow device was interrupted before any data arrived by the delivery of a signal. [EINVAL] The pointer associated with d was negative. [EWOULDBLOCK] The file was marked for non-blocking I/O, and no data were ready to be read. In addition, readv may return one of the following errors: [EINVAL] Iovcnt was less than or equal to 0, or greater than 16. [EINVAL] The sum of the iov_len values in the iov array overflowed a short. [EFAULT] Part of the iov points outside the process's allocated address space. SEE ALSO
dup(2), fcntl(2), open(2), pipe(2), select(2), socket(2), socketpair(2) 4th Berkeley Distribution August 1, 1987 READ(2)
All times are GMT -4. The time now is 10:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy