11-16-2002
read system call
When i read 4 bytes from a socket the read function returns 0 value. what does it mean?
How should i know whether a message is available in the socket or not?
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
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
How the c compiler differentiates the system calls and function calls? (1 Reply)
Discussion started by: rangaswamy
1 Replies
3. Shell Programming and Scripting
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
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
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
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
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
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
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
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
LEARN ABOUT PHP
stream_socket_recvfrom
STREAM_SOCKET_RECVFROM(3) 1 STREAM_SOCKET_RECVFROM(3)
stream_socket_recvfrom - Receives data from a socket, connected or not
SYNOPSIS
string stream_socket_recvfrom (resource $socket, int $length, [int $flags], [string &$address])
DESCRIPTION
stream_socket_recvfrom(3) accepts data from a remote socket up to $length bytes.
PARAMETERS
o $socket
- The remote socket.
o $length
- The number of bytes to receive from the $socket.
o $flags
- The value of $flags can be any combination of the following:
Possible values for $flags
+------------+---------------------------------------------------+
| | |
|STREAM_OOB | |
| | |
| | Process OOB ( out-of-band) data. |
| | |
| | |
|STREAM_PEEK | |
| | |
| | Retrieve data from the socket, but do not con- |
| | sume the buffer. Subsequent calls to fread(3) or |
| | stream_socket_recvfrom(3) will see the same data. |
| | |
+------------+---------------------------------------------------+
o $address
- If $address is provided it will be populated with the address of the remote socket.
RETURN VALUES
Returns the read data, as a string
EXAMPLES
Example #1
stream_socket_recvfrom(3) example
<?php
/* Open a server socket to port 1234 on localhost */
$server = stream_socket_server('tcp://127.0.0.1:1234');
/* Accept a connection */
$socket = stream_socket_accept($server);
/* Grab a packet (1500 is a typical MTU size) of OOB data */
echo "Received Out-Of-Band: '" . stream_socket_recvfrom($socket, 1500, STREAM_OOB) . "'
";
/* Take a peek at the normal in-band data, but don't comsume it. */
echo "Data: '" . stream_socket_recvfrom($socket, 1500, STREAM_PEEK) . "'
";
/* Get the exact same packet again, but remove it from the buffer this time. */
echo "Data: '" . stream_socket_recvfrom($socket, 1500) . "'
";
/* Close it up */
fclose($socket);
fclose($server);
?>
NOTES
Note
If a message received is longer than the $length parameter, excess bytes may be discarded depending on the type of socket the mes-
sage is received from (such as UDP).
Note
Calls to stream_socket_recvfrom(3) on socket-based streams, after calls to buffer-based stream functions (like fread(3) or
stream_get_line(3)) read data directly from the socket and bypass the stream buffer.
SEE ALSO
stream_socket_sendto(3), stream_socket_client(3), stream_socket_server(3).
PHP Documentation Group STREAM_SOCKET_RECVFROM(3)