02-03-2004
i definitely think select rocks too
![Smilie Smilie](https://www.unix.com/images/smilies/smile.gif)
...i just put it in the main a infinite loop with select inside
while (1) {
build_select_list();
timeout.tv_sec = 1;
timeout.tv_usec = 0;
readsocks = select(highsock+1, &socks, (fd_set *) 0,
(fd_set *) 0, &timeout);
if(readsocks>0)
read_socks();
}
and then accept the sock and go to read my buffer.
i also made every sock that connects nonblocking by setting the flags with fcntl(i don't know if it's the best thing)
In this case the server never ever block and that's good, but it happens sometimes the client (which is a control system with a readymade module for TCP IP client that i cannot change) goes up and down with the connection for hundreds times in a row before staying connected ... is the tcp ip so instable or there's something wrong?
anyway thanx again for your precious helping
![Smilie Smilie](https://www.unix.com/images/smilies/smile.gif)
10 More Discussions You Might Find Interesting
1. IP Networking
Requirements:
A server program should read a file and send the message to the client . if the file is not there, then switch to the receive part of the same program and receive any messages from the socket. If no messages to receive then switch to send part of the program to... (2 Replies)
Discussion started by: Rajeshsu
2 Replies
2. UNIX for Dummies Questions & Answers
I have true64 Unix running and there a scales in the sytem which connect thru a com-server to the network. they have their own IP-address and are communicating over port 8000. when I telnet to the com-servers and the print function of the scale is executed I can see the data coming.
I need to know... (1 Reply)
Discussion started by: albinhess
1 Replies
3. Programming
Please tell me according to C/C++ socket programming; how client can check whether server is running or not during TCP communication. (1 Reply)
Discussion started by: mansoorulhaq
1 Replies
4. Programming
Hi,
I am new to using threads in C++ though I have been wkring on C++ for past 1.5 years...I want to write a TCP server that serves multiple client connections...to start off..i have been working on a simple tcp echo server trying to understand how threads work....
this is my server code:
... (5 Replies)
Discussion started by: deepti_v25
5 Replies
5. IP Networking
We have a NAS application which can be accessed by both HTTP and HTTPS connections.
The issue we are facing is that the tcp server instance that initiates the HTTP access dies after a few hours of inactivity(the NAS application was kept idle for around 10 hours). However, the tcpserver that... (1 Reply)
Discussion started by: swatidas11
1 Replies
6. Programming
Hello @ all,
I hope you can give me some advice :b:
I will be following code for a tcp server and doStuff () function, the
clients treated. From some point, I have several identical
clients (zombies, I think), the same records in the database
write. Has anyone an explanation? What can I... (1 Reply)
Discussion started by: yumos
1 Replies
7. Programming
I made a program and now I need to make it concurrent.
Can someone pls help me do this ?
The code is this:
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <errno.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>... (4 Replies)
Discussion started by: Johnny22
4 Replies
8. Solaris
Hi,
I am having a solaris server. I want to start a dummy TCP listner on UNIX OS on a specific port can anyone please let me know the process.
IP ADDRESS: 123.123.123.123
Port: 8010 (1 Reply)
Discussion started by: mayank2211
1 Replies
9. UNIX for Dummies Questions & Answers
I am trying to send json messages to a port on a linux server from a remote server running a .net program. I have one implementation running with successful incoming messages to port 1514. I tried to replicate the same thing but just to another port but cannot get it to work as I get the following... (3 Replies)
Discussion started by: unienewbie
3 Replies
10. Solaris
I have problem with oracle solaris 10 running on oracle sparc T4-2 server.
Os information: 5.10 Generic_150400-03 sun4v sparc sun4v
Output from tcpstat.d script
TCP bytes: out outRetrans in inDup inUnorder
6833763 7300 98884 0... (2 Replies)
Discussion started by: insatiable1610
2 Replies
LEARN ABOUT DEBIAN
vga_waitevent
vga_waitevent(3) Svgalib User Manual vga_waitevent(3)
NAME
vga_waitevent - wait for various I/O events
SYNOPSIS
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <vga.h>
int vga_waitevent(int which, fd_set *input, fd_set *output , fd_set *except, struct timeval *timeout)
DESCRIPTION
This is the only function allowing you to wait for keyboard AND mouse events. It is based on the select(2) library function, so for deep
understanding of vga_waitevent() look at select(2) as well.
which can be 0 or logical ored together from VGA_MOUSEEVENT and VGA_KEYEVENT. If you are interested in waiting for file descriptors having
input available or being ready for new write data or being in an exceptional condition (urgent data arrived on a TCP stream) set the corre-
sponding bits in the fd_set structures passed (see select(3)). If you want vga_waitevent() to return after a timeout value pass a struct
timeval with the desired value. If you are not interested in the corresponding events you may pass NULL for any of the pointers.
If NULL is passed for timeout vga_waitevent() will not time out but block until any of the other events occurs. If the integer returned is
< 0 an error occurred. Check the global variable errno for details. If a value >= 0 is returned it is a bitmask constructed using
VGA_MOUSEEVENT and VGA_KEYEVENT to show which of these events occured.
If any of these two occured the appropriate update functions are already called by vga_waitevent().vga_waitevent() operates in raw as well
as non-raw keyboard mode. In the latter case use vga_getch(3) not vga_getkey(3) to read the newly arrived keys.
Any of the file related conditions being met will be signalled by setting exactly the bits for files that met the conditions in the corre-
sponding fd_set structures. If a non-NULL timeout is passed the remaining time is written into it on return. If it is 0 a timeout occured.
(again: cf. select(2)) Therefore, depending on context, vga_waitkey(3) may return 0 if only special, non svgalib, events occured.
EXAMPLES
If you want to wait blocking for a keypress OR a mouse event use: vga_waitevent(VGA_MOUSEEVENT | VGA_KEYEVENT, NULL, NULL, NULL, NULL);
If you want to wait for a keypress OR a mouse event but non-blocking use:
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <vga.h>
struct timeval timeout;
timeout.tv_sec = 0;
timeout.tv_usec = 0;
vga_waitevent(VGA_MOUSEEVENT | VGA_KEYEVENT, NULL, NULL, NULL, &timeout);
You could do a similar thing by just calling
mouse_update();
keyboard_update();
though. There is no such counterpart for the first example.
Finally, there is a very nice eventtest(6) demo showing most capabilities of vga_waitevent().
BUGS
This function was introduced in 1.2.10. Unfortunately there was a typo in the first implementation which broke the case where input was
NULL. Though fixed in 1.2.11 for optimal portability pass an empty fd_set instead of NULL as first argument.
When not running in background mode, that is, the svgalib applcation is suspended while the VC is switched away, it seems vga_waitevent
gets stuck and does no longer timeout. It is not clear if this is an svgalib bug, kernel bug or general problem.
SEE ALSO
svgalib(7), vgagl(7), libvga.config(5), eventtest(6), mouse_getposition_6d(3), mouse_getx(3), mouse_update(3), mouse_waitforupdate(3),
vga_getkey(3), vga_getch(3)
AUTHOR
This manual page was edited by Michael Weller <eowmob@exp-math.uni-essen.de>. The exact source of the referenced function as well as of the
original documentation is unknown.
It is very likely that both are at least to some extent are due to Harm Hanemaayer <H.Hanemaayer@inter.nl.net>.
Occasionally this might be wrong. I hereby asked to be excused by the original author and will happily accept any additions or corrections
to this first version of the svgalib manual.
Svgalib (>= 1.2.11) 27 July 1997 vga_waitevent(3)