socket async io



  • 1. Getting an error: Syntax error at the end of input
    I have one program and when I try to copile it using the make file it is giving me an error: Syntax error at the end input.... I am getting two warnings before this error which says "Warning: no previous prototype for slmics_creare" I have this function defined very well.... So is the error because of these warnings or what???? But I am not finding any syntax error at the end ..... Can any one please help.... I even not understanding what sohuld I include to give you good idea about from where the problem is coming so please let me know.....
  • 2. High-Speed TCP/IP Message Logging
    Hi, I am at a complete loss for ideas on how to solve the following problem. My single-threaded TCP/IP server has three types of messages arriving on three separate sockets each at around a rate of 10Hz of size 300-400KB (yes, large! unfortunately no way around this). At worst case this results in approximately 12MB/sec throughput. Unfortunately I cannot implement the server in such a way that it can keep up. Each message needs to be logged to disk, but the fwrite() takes much longer than the recv() from the socket, so things just choke up on the remote end eventually. I have tried: 1) Using a separate thread which writes a continously-building linked list of messages to disk 2) Memory mapped I/O - this eventually becomes horribly slow once the process starts swapping Am I simply constrained by Little's Theorem for FIFO queues and the fact that the service time is not fast enough? Do I just need a faster storage device than an ordinary hard-disk? Any input would be greatly appreciated. PS. This is running on a Sun Sparc which is plenty fast...
  • 3. Questions on POSIX-eness of pipes and UDP datagrams
    Hello, I could not find reliable information to answer a few questions I have on pipes and UDP sockets: -can I change the pipe's (any kind: anonymous, etc) buffer size? Will it be portable/POSIX -is there a way to find out the IP of the sender of a datagram if the UDP socket was not connected? Will it be portable/POSIX -is there a portable way to change the buffer size of an UDP socket? Will it be portable/POSIX -what is the maximum size of a datagram guaranteed to be delivered without being truncated? Thanks a.

socket async io

Postby Xend » Sat, 22 Nov 2008 18:25:27 GMT

can i use fcntl(socket_fd, F_SETSIG, signum) to get asycn event on
socket_fd with socket.

Re: socket async io

Postby Maxim Yegorushkin » Sat, 22 Nov 2008 19:20:41 GMT

You can, but it is pretty much useless because it is very inconvenient
to deal with signals for doing IO. It is much more convenient to use
non-blocking IO (select, pool, epoll, ...) or aio_ family of functions
(aio_read and friends).



Re: socket async io

Postby Rainer Weikusat » Sat, 22 Nov 2008 22:06:29 GMT

Xend < XXXX@XXXXX.COM > writes:

On Linux, yes. But (AFAIK) asynchronous I/O with the help of signals
is only availabe either on Linux or *BSD.

Re: socket async io

Postby Rainer Weikusat » Sat, 22 Nov 2008 22:15:12 GMT

Maxim Yegorushkin < XXXX@XXXXX.COM > writes:

I have several programs which use signal-driven I/O for various
reasons, the most important being the absence of a extended
multiplexing mechansim other than using queued RT signals on Linux
2.4. Using edge triggered I/O readiness notifaction requires
marginally more complicated code than using a level-triggered
interface. But dealing with signal-driven I/O or signals in general
isn't least bit of what I would consider 'inconvenient to the point of
[*] That 9.5 out of 7 hardware designers cannot think of any other
event notification mechanism than high-freqeuncy polling of a
(conceptually) passive data source has so far not led to the
un-invention of interrupts :->>.

Re: socket async io

Postby Maxim Yegorushkin » Sat, 22 Nov 2008 23:54:42 GMT

What does it prove?

I was not referring to edge-triggered I/O.

Given choice of demultiplexing using select, poll, epoll, etc.. and
signal driven I/O, I consider demultiplexing more convenient. But this
is just my opinion.



Re: socket async io

Postby Rainer Weikusat » Sun, 23 Nov 2008 00:24:23 GMT

Maxim Yegorushkin < XXXX@XXXXX.COM > writes:

That both of us have access to USENET although none of us must
necessarily be a human and not a script?

No, I was. Using signal-driven I/O implies using edge-triggered
I/O-readiness notfication and this is, in turn, (marginally) more
complicated than using level-triggered I/O-readiness notification. But
that's caused by the edge-triggerdness of the mechanism and not by
its use of signals to deliver the notifications.

So far, this is your firm belief. In my opinion, your belief is
misguided because I couldn't find anything particularly inconvenient
when using signal-driven I/O except the abovementioned


"All you can eat".

Similar Threads:

1.Need help with a simple UNIX sockets server based on IO::Socket::UNIX

Hi. I've tried to create a simple client + server that communicate
through a unix socket.

As with all socket servers, it has a loop where it waits for

while ($client = $sock->accept()) {
  # handle client here

The problem is that $sock->accept() is returning undef on each
alternate client connection with error "No child processes".

I made this temporary workaround that does work but of course I must be
screwing up somewhere else:

while ($client = $sock->accept() || $client = $sock->accept()) {
  # handle client here

I hope someone can help or provide an example. I've included the client
+ server code below for those who are interrested in taking a peek.

Craig Manley

############ client ############
#!/usr/bin/perl -w
use strict;
use IO::Socket;

my $sockname = 'mysocket';

my $client = IO::Socket::UNIX->new('Peer' => $sockname,
                                   'Type' => SOCK_STREAM,
                                   'Timeout' => 50) or die "$0: error
connecting to '$sockname': $ [at] \n";
my $pid = fork();
unless(defined($pid)) {
  die("Fork this! I cannot forking fork!\n");
if ($pid) {
  waitpid($pid, 0);
else {

sub write_sock {
  for (1..10) {
    print $client "testline number $_\n"; # print to socket
  print $client "\n"; # empty line causes server to terminate
  print "Done writing.\n"; # (goes to stdout, not socket)

sub read_sock {
  while (my $line = <$client>) {
    print $line; # report to stdout
    # simulate someone reading slooowly (50ms/line):
    select(undef, undef, undef, 0.05);

########### server ############
#!/usr/bin/perl -w
use strict;
use IO::Socket;
use POSIX ":sys_wait_h"; # (for WNOHANG)
use Data::Dumper qw(Dumper);

# example using unix domain socks
# once the file is created as a socket, any client can
# interact with it

my $sockname = 'mysocket';

service_clients( get_sock() ); # wait for incoming requests

sub get_sock {
  unlink $sockname;
  my $sock = IO::Socket::UNIX->new('Local'  => $sockname,
                                   'Type'   => SOCK_STREAM,
                                   'Listen' => SOMAXCONN) || die "$0:
error starting daemon on '$sockname': $ [at] \n";
  # you might want to change permissions and ownership, e.g.:
  #chmod 0600, $sockname;
  #chown scalar getpwnam('nobody'), 0, $sockname;
  return $sock;

sub service_clients {
  my $sock = shift;
  $SIG{CHLD} = \&reaper;
  my $client;
  while ($client = $sock->accept()) { # Why the hell does it return
undef on the next iteration?
  # while ($client = $sock->accept() || $client = $sock->accept()) { #
This strangely enough does work.

    # fork yet another process to prevent buffer deadlock. one proc
writes to
    # the sock, the other reads the deamons response
    my $pid = fork();
    unless(defined($pid)) {
      die("Fork this! I cannot forking fork!\n");
    if ($pid) { # parent
      print "$pid $$: I'm the parent and am going to wait for another
      close($client); # no use to parent
      next; # be ready for another client
    print "$pid $$: I'm the child and I'm going to service the
    # child
    close($sock); # no use to child
    print "$pid $$: I'm the child and I'm going to exit.\n";
    exit; # terminate child
  print "Damnit! I'm the server and I finished unexpectedly: $!\n";

sub process_requests {
  my $client = shift;
  $0 = "unixsockd: handling requests...";
  # read from client until empty line which causes it to close
  while ( my $line = <$client> ) { # read line from socket
    if ($line =~ /^\s$/) {
      last; # exit on empty line
    # put some more useful code here to read each line or whatever...
    printf $client "%s: %s, handled by PID %d\n",
    scalar localtime(time), $line, $$;
    # return something to client

sub reaper {
  while (waitpid(-1,WNOHANG) > 0) {}
  $SIG{CHLD} = \&reaper;

2.directio and async io on redhat linux 3 and oracle 9i

Hi Folks

I have enabled directio and async io on my redhat box.

Async io is verified by running the classical cat
/etc/proc/slabinfo|grep kio

How do i verify direct io is being used by oracle.

I know of one way to do it is tracing the dbwr and seeing whether fopen
call is with o_direct flags.But the strange thing is when i say

sqlplus>conn /as sysdba;

sqlplus>oradebug setospid <<ospid-of-dbwriter>>

no trace file is being produced.Can somebody tell me what magic needs
to be done by me :-)


3.Redhat linux and async io


Oracle10g (32 bit)
RHEL 4 update 3 (32 bit)

* I have installed the async io rpm's
$ rpm -qa | grep aio

1) How do i verify/check if the async io is enabled/loaded in RHEL
I solaris I used to
$ modinfo | grep kaio
142  1344ccb   4916 178   1  kaio (kernel Async I/O)
142  1344ccb   4916 178   1  kaio (kernel Async I/O for 32 bit com)

One of the Metalink docs says check
$ cat /proc/slabinfo | grep kio

2) How do I determine if the redlat linux installed is 32 or 64 bit
Is getconf LONG_BIT the only way to determine this or will uname -a
show something specific.

Thanks for your help.

4.async io

How do I enable async io on solaris 8 2/02 ?  How do I tell if it is enabled
if using veritas foundation suite?

5.How to provide Async IO support in a driver


I am having trouble getting the aio_read and aio_suspend calls to work
properly with a driver we have written to do DMA transfers via the PCI bus.
I do not know if the driver is properly configured to enable the async
xxxaread cb_ops function.  I have searched high and low and cannot find
anything written on this topic.  Does anyone know under what conditions the
xxxaread cb_ops function is called?  In tracing my drivers activity, even
though I call aio_read from the user process, the xxxread cb_ops is always
called by the kernel.  Although I am able to start the DMA, I am having
trouble getting biodone to properly notify the user process, particularly
when it is called from a timeout routine.

I am running Solaris 8/9.  Any information on how to properly write drivers
that support async io or how to properly time out DMA completion would be
greatly appreciated.



6. [PATCH] [1/3] writes: report truncate and io errors on async writes

7. [PATCH 5/5] direct-io: fix double completion on partially valid async requests

8. [PATCH 4/5] direct-io: unify sync and async completion paths

Return to unix


Who is online

Users browsing this forum: No registered users and 5 guest