Sponsored Content
Top Forums Programming Need help about read() and write() on TCP/IP Post 302469669 by Corona688 on Sunday 7th of November 2010 02:20:12 PM
Old 11-07-2010
Just like you can save anything you want in a file, you can send anything you want over a socket. You must decide what bytes of data you will send to mean what. Are you sending lines of text? Are you sending binary structures? Something else? What are you doing?
 

10 More Discussions You Might Find Interesting

1. Programming

popening for read and write

How can 'popen()' be used for reading and writing to opening pipe? If i try 'popen("prog", "rw")' and then put and get chars - it does not work. What is wrong? (1 Reply)
Discussion started by: szzz
1 Replies

2. Shell Programming and Scripting

read and write from a file

I have tried to show the file name whose size is greater than 200 byte in current directory. Please help me. ls -l | tr -s " " " " | cut -f 5,9 -d " " >out.txt #set -a x `cat out.txt` i=0 `cat out.txt` | while do read x echo $x #re=200 j=0 if }" < "200" ] then echo $j j=`expr $j... (2 Replies)
Discussion started by: rinku
2 Replies

3. Shell Programming and Scripting

Find all files with group read OR group write OR user write permission

I need to find all the files that have group Read or Write permission or files that have user write permission. This is what I have so far: find . -exec ls -l {} \; | awk '/-...rw..w./ {print $1 " " $3 " " $4 " " $9}' It shows me all files where group read = true, group write = true... (5 Replies)
Discussion started by: shunter63
5 Replies

4. Programming

read/write files

Hi all, I have a problem with some read/write functions. I have a .bin file which contains a lot of structures as follows: struct alumno { char id; char apellido1; char apellido2; char nombre; float nota1p; float nota2p; float notamedia; char photofilename; }; What I have... (3 Replies)
Discussion started by: Attenea
3 Replies

5. IP Networking

read/write,write/write lock with smbclient fails

Hi, We have smb client running on two of the linux boxes and smb server on another linux system. During a backup operation which uses smb, read of a file was allowed while write to the same file was going on.Also simultaneous writes to the same file were allowed.Following are the settings in the... (1 Reply)
Discussion started by: swatidas11
1 Replies

6. IP Networking

write() / read() syntax

hi am newbie to unix and socket programing I am trying to figuring out syntax for read and write to send data from server to client and client can read it I have to send two integers write(newsockfd,buffer,"%d %d",x,y,0) writing from client where x and y are two integers.. ... (7 Replies)
Discussion started by: karthik1238
7 Replies

7. Shell Programming and Scripting

Read and write to tcp socket

Hello all, I have a requirement to read and write to a tcp socket from an HP-UX shell script. I see a /dev/tcp character device on my servers: crw-rw-rw- 1 root root 72 0x00004f Mar 28 18:37 /dev/tcp So I believe this is what I should use. The problem is that all the... (2 Replies)
Discussion started by: lupin..the..3rd
2 Replies

8. Shell Programming and Scripting

File Read and Write

I have got a file in following format: AAAAAAA BBBBBBBB CCCCCCC DDDDDDD I am trying to read this file and out put it in following format: AAAAAAA,BBBBBBB,CCCCCCC,DDDDDD Preferred method is shell or Perl. Any help appreciated. (11 Replies)
Discussion started by: Araoki
11 Replies

9. Shell Programming and Scripting

Read and write in the file

Hello Guys, How all are doing? I have an issue in Unix and want help from all of you I have a file in UNIX which it read by line by line , If at the end of line '0' is written the it should fetch that line into another file and change '0' to '1' and If at the end of line '1' is written then it... (10 Replies)
Discussion started by: adisky123
10 Replies

10. Programming

FIFO write and read

Can someone help me to write this program in C in QNX? Using the FIFO queues write a simple communication system consisting of programs write and read. The program write the parameters given strings enclosed in single quotes. These strings are written to the FIFO file. Reads the program read... (1 Reply)
Discussion started by: ebasse2
1 Replies
SEND(P) 						     POSIX Programmer's Manual							   SEND(P)

NAME
send - send a message on a socket SYNOPSIS
#include <sys/socket.h> ssize_t send(int socket, const void *buffer, size_t length, int flags); DESCRIPTION
The send() function shall initiate transmission of a message from the specified socket to its peer. The send() function shall send a mes- sage only when the socket is connected (including when the peer of a connectionless socket has been set via connect()). The send() function takes the following arguments: socket Specifies the socket file descriptor. buffer Points to the buffer containing the message to send. length Specifies the length of the message in bytes. flags Specifies the type of message transmission. Values of this argument are formed by logically OR'ing zero or more of the following flags: MSG_EOR Terminates a record (if supported by the protocol). MSG_OOB Sends out-of-band data on sockets that support out-of-band communications. The significance and semantics of out-of-band data are protocol-specific. The length of the message to be sent is specified by the length argument. If the message is too long to pass through the underlying proto- col, send() shall fail and no data shall be transmitted. Successful completion of a call to send() does not guarantee delivery of the message. A return value of -1 indicates only locally-detected errors. If space is not available at the sending socket to hold the message to be transmitted, and the socket file descriptor does not have O_NON- BLOCK set, send() shall block until space is available. If space is not available at the sending socket to hold the message to be trans- mitted, and the socket file descriptor does have O_NONBLOCK set, send() shall fail. The select() and poll() functions can be used to deter- mine when it is possible to send more data. The socket in use may require the process to have appropriate privileges to use the send() function. RETURN VALUE
Upon successful completion, send() shall return the number of bytes sent. Otherwise, -1 shall be returned and errno set to indicate the error. ERRORS
The send() function shall fail if: EAGAIN or EWOULDBLOCK The socket's file descriptor is marked O_NONBLOCK and the requested operation would block. EBADF The socket argument is not a valid file descriptor. ECONNRESET A connection was forcibly closed by a peer. EDESTADDRREQ The socket is not connection-mode and no peer address is set. EINTR A signal interrupted send() before any data was transmitted. EMSGSIZE The message is too large to be sent all at once, as the socket requires. ENOTCONN The socket is not connected or otherwise has not had the peer pre-specified. ENOTSOCK The socket argument does not refer to a socket. EOPNOTSUPP The socket argument is associated with a socket that does not support one or more of the values set in flags. EPIPE The socket is shut down for writing, or the socket is connection-mode and is no longer connected. In the latter case, and if the socket is of type SOCK_STREAM, the SIGPIPE signal is generated to the calling thread. The send() function may fail if: EACCES The calling process does not have the appropriate privileges. EIO An I/O error occurred while reading from or writing to the file system. ENETDOWN The local network interface used to reach the destination is down. ENETUNREACH No route to the network is present. ENOBUFS Insufficient resources were available in the system to perform the operation. The following sections are informative. EXAMPLES
None. APPLICATION USAGE
The send() function is equivalent to sendto() with a null pointer dest_len argument, and to write() if no flags are used. RATIONALE
None. FUTURE DIRECTIONS
None. SEE ALSO
connect() , getsockopt() , poll() , recv() , recvfrom() , recvmsg() , select() , sendmsg() , sendto() , setsockopt() , shutdown() , socket() , the Base Definitions volume of IEEE Std 1003.1-2001, <sys/socket.h> COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technol- ogy -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html . IEEE
/The Open Group 2003 SEND(P)
All times are GMT -4. The time now is 09:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy