Sponsored Content
Top Forums Programming Anyone know how to use socket select() function? Post 302159464 by draggy on Thursday 17th of January 2008 09:44:34 PM
Old 01-17-2008
Quote:
Originally Posted by ramen_noodle
I've attached a hasty, single process server (without any signal handling) example that works on my FreeBSD 6.0 host. Hopefully it will be of assistance. I'd suggest running indent against it. There are also very good arguments for not using select in favor of pselect. Also for high capacity servers maybe kqueue would be better.

HTH
Thank you for reply and your example is very good :-D

btw, I will come back later in time to report my progress on how is the development is going on :-D
 

10 More Discussions You Might Find Interesting

1. Programming

How to convert the "select" function into a "poll" function

i have a program using the select function but i want to convert it to poll... how can i do this? thanks in advance... :) (1 Reply)
Discussion started by: rbolante
1 Replies

2. Shell Programming and Scripting

send function in socket

Hi All, I encountered a stange problem while doing a perl script to use socket. i need to transfer a file from client to sever. but error came as argument missing in send function.........Plz tell me the wt r the arguments in send and recv functions....... (0 Replies)
Discussion started by: trupti_rinku
0 Replies

3. Programming

select function

Dear all, I am using select function for the socket programming. What is the purpose of except fd's fd set in the argument. (0 Replies)
Discussion started by: nagalenoj
0 Replies

4. Programming

Multiplexing socket and message queue using Select()

I have a socket and a message queue over which i am trying to multiplex input using select(). When data comes over socket the select works but when it comes over message queue the select is not detecting it . Create_Q gets the identifier of the messege queue. ... (1 Reply)
Discussion started by: shaurya.rastogi
1 Replies

5. Programming

connect() function in C++ socket programming

Hello All, I have a problem using connect(...) function in C++. I am using SSH from my windows system to connect it to linux server. The program works fine if I run it directly in Linux machine but I need it to run through windows machine. The function returns -1 and so my program terminates. ... (3 Replies)
Discussion started by: smdhd3
3 Replies

6. Programming

Please help! accept function problems in Socket programming

Hi, I have a client-server socket program. It has been working fine for over a year, but recently it started to show strange behavior.:confused: After the server program runs for a while, it will show in the top command saying it is using lots of CPU, MEM. I assume it means the server code is... (1 Reply)
Discussion started by: natxie
1 Replies

7. UNIX for Advanced & Expert Users

connect problem for sctp socket (ipv6 socket) - Runtime fail Invalid Arguments

Hi, I was porting ipv4 application to ipv6; i was done with TCP transports. Now i am facing problem with SCTp transport at runtime. To test SCTP transport I am using following server and client socket programs. Server program runs fine, but client program fails giving Invalid Arguments for... (0 Replies)
Discussion started by: chandrutiptur
0 Replies

8. Programming

socket function to read a webpage (socket.h)

Why does this socket function only read the first 1440 chars of the stream. Why not the whole stream ? I checked it with gdm and valgrind and everything seems correct... #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <string.h> #include... (3 Replies)
Discussion started by: cyler
3 Replies

9. Programming

I am a little bit confused in a socket example through select()

Hi, I am a newbie about network programming. All codes come from this book: UNIX Network Programming Volume 1, Third Edition. It is a TCP server by use select() int main(int argc, char **argv) { int i, maxi, maxfd, listenfd, connfd, sockfd; int ... (2 Replies)
Discussion started by: sehang
2 Replies

10. Programming

Socket and select

I have created two sockets and binded both. My requirement is that 2nd socket must send/ recv data only on expiration of timeval(tv). but the 1st socket must keep on send/recv the data without waiting for the 2nd socket completion...... I have posted my code below...... In this code the 2nd... (3 Replies)
Discussion started by: naresh046
3 Replies
send(2) 							System Calls Manual							   send(2)

NAME
send - Sends messages on a socket SYNOPSIS
#include <sys/socket.h> ssize_t send ( int socket, const void *buffer, size_t length, int flags ); [Tru64 UNIX] The following definition of the send() function does not conform to current standards and is supported only for backward compatibility (see standards(5)): int send ( int socket, char *message, int length, int flags ); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: send(): XNS5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Specifies the unique name for the socket. Points to the buffer containing the message to send. Specifies the length of the message in bytes. Allows the sender to control the transmission of the message. The flags parameter to send a call is formed by logically ORing the values shown in the following list, defined in the sys/socket.h header file: Sends out-of-band data on sockets that support out-of-band communication. Sends without using routing tables. (Not recommended, for debugging purposes only.) DESCRIPTION
The send() function sends a message only when the socket is connected (this includes when the peer of a connectionless socket has been set with a connect() call). The sendto() and sendmsg() functions can be used with unconnected or connected sockets. Specify the length of the message with the length parameter. If the message is too long to pass through the underlying protocol, the sys- tem returns an error and does not transmit the message. No indication of failure to deliver is implied in a send() function. A return value of -1 indicates only locally detected errors. If no space for messages is available at the sending socket to hold the message to be transmitted, the send() function blocks unless the socket is in a nonblocking I/O mode. Use the select() function to determine when it is possible to send more data. The socket in use may also require that the calling process have appropriate privileges. NOTES
[Tru64 UNIX] The send() function is identical to the sendto() function with a zero-valued dest_len parameter, and to the write() function if no flags are used. For that reason, the send() function is disabled when 4.4BSD behavior is enabled (that is, when the _SOCKADDR_LEN compile-time option is defined). RETURN VALUES
Upon successful completion, the send() function returns the number of characters sent. Otherwise, a value of -1 is returned and errno is set to indicate the error. ERRORS
If the send() function fails, errno may be set to one of the following values: The calling proces does not have the appropriate privileges. The socket parameter is not valid. A connection was forcibly closed by a peer. The socket is not connection-oriented and no peer address is set. The buffer parameter cannot be accessed. [Tru64 UNIX] The message parameter is not in a readable or writable part of the user address space. A signal interrupted send before any data was transmitted. An I/O error occurred while reading from or writing to the file system. The message is too large to be sent all at once, as the socket requires. The local network connection is not operational. The destination network is unreachable. Insufficient resources were available in the system to complete the call. The available STREAMS resources were insuf- ficient for the operation to complete. The socket is not connected or otherwise has not had the peer prespecified. The socket parameter refers to a file, not a socket. The socket argument is associated with a socket that does not support one or more of the values set in flags. The socket is shut down for writing, or the socket is connection-oriented and the peer is closed or shut down for reading. In the latter case, and if the socket is of type SOCK_STREAM, the SIGPIPE signal is generated to the calling process. The socket is marked nonblocking, and no space is available for the send() function. RELATED INFORMATION
Functions: connect(2), getsockopt(2), poll(2), recv(2), recvfrom(2), recvmsg(2), select(2), sendmsg(2), sendto(2), setsockopt(2), shut- down(2), socket(2), Standards: standards(5) delim off send(2)
All times are GMT -4. The time now is 09:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy