Re: Socket Connection
- From: Larry Morley <lmorley albany net>
- To: Tom Carter <tcarter reliable-net net>
- Cc: gtk-list gnome org
- Subject: Re: Socket Connection
- Date: Fri, 19 May 2000 13:52:43 -0400
Tom,
What are you doing when you get SIGPIPE? Are you sure that you're
getting SIGPIPE and not EACCCES (the values for the two are the same;
13; at least with Solaris 7 & gcc 2.8.1). The return value should
be < 0 from whatever socket function call (socket(), bind() etc.)
you're using, and "errno" will be set to the actual error code (see
sys/errno.h). If your app is compiled as reentrant, errno() (func-
tion call) is used in place of errno (extern int variable). See
man socket, man bind, etc.
To get SIGPIPE, you would have to have called signal() to establish
a signal handler for it. I've never seen SIGPIPE raised for a
socket; that one's a signal that's raised by the OS when you're att-
empting to write to a pipe which can't be read by anything; when the
readable end of the pipe is inaccessable to other process, thread,
etc. EACCES is pretty common though; especially for ports in the
privileged socket range when the app-in-question is running as a
normal user. Try running the app as root and see if the error goes
away; if it does, this is probably the case. Try using a higher port
number (one outside of the priv. range). The port might also be in
use, though you should receive EINUSE in this case. The only signal
I usually catch in my apps that use sockets (aside from those to
catch UI related signals) is SIGCHILD, to avoid zombies when I fork
a child in an app where the child process is blocking on accept()
after a listen().
Hope this helps. Good luck.
- Larry Morley
P.S. While I generally compile my own gcc, the versions I've checked
out on the sunfreeware site have seemed to work fine. I've got one
machine using a version from that site, and several colleagues that
use their packages; I haven't heard any negative feedback or had any
problems of my own with their software.
> Tom Carter wrote:
>
> I am using Solaris 8 and the Solaris Free Ware version of gcc, gtk,
> and glib.
>
> I am using gtk to add xwindowing capabilities to our application
> (message switching).
>
>
> I connect the application to the xwindows programs via sockets.
>
> The application starts from the command line in a dtterm window.
>
> Once started, it the application forks and executes the initial gtk
> program and then creates a socket.
>
> The gtk xwindows program then connects to the socket established by
> the application.
>
> In general this works great.
>
> However, if I use a command line argument when starting the
> application, the gtk xwindows program can connect and read the socket,
> but cannot write to the socket. It always gets a SIGPIPE error when
> it tries. I am confused and baffled why a single command line
> argument could cause this.
>
> I have also tried this under SCO OpenServer 5.0.5 with an older
> version of gtk, gcc, and glib, and this particular problem does not
> occur.
>
> Is this an OS problem? A Linking problem?
>
> Thanks
>
> Tcarter
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]