This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

sockets and forking under W95


hi
The following is a code snippet from a simple program I am trying to get
going. It compiles and works fine on an Aix machine but when I try it under
gnuwin32 it compiles and links fine but when I hit the fork () function in
main() I get a stack dump also included. I am running on W95 with the latest
coolview. I seem to recall reading here at some stage about problems with
sockets and forking in W95 but cannot remember the details.
any clues? thanks.

Colman.

//===================================================
int create_listen_socket(int port)
{
	int		s;
	struct sockaddr_in	sin;

	if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0)
	{
		perror("Can't create socket");
		return(-1);
	}

	sin.sin_family	= AF_INET;
	sin.sin_port		= htons(ntohs(port));
	sin.sin_addr.s_addr	= htonl(INADDR_ANY);

	if (bind(s, (struct sockaddr *) &sin, sizeof(sin)) == -1)
	{
		perror("Can't bind to socket");
		(void) close(s);
		return(-1);
	}

	listen(s, 5);

	return(s);
}

int main(int argc, char **argv)
{
	int		mypid;

	if ((sock = create_listen_socket(PORT_NUMBER)) < 0)
	{
		(void) fprintf(stderr, "Failed to create socket\n");
		exit(sock);
	}

	if ((mypid = fork()) == -1)
	{
		perror("Error forking");
		exit(mypid);
	}
	else if (mypid > 0)				/* Parent 	*/
	.
	.
	[snip]
	.
	.
}
//===================================================
(C:\USR\SRC\PIPER\RPRD.EXE 1005) In cygwin_except_handler exc C0000005 at
41000C
 sp 253F03C
(C:\USR\SRC\PIPER\RPRD.EXE 1005) Exception trapped!
(C:\USR\SRC\PIPER\RPRD.EXE 1005) exception C0000005 at 41000C
(C:\USR\SRC\PIPER\RPRD.EXE 1005) exception: ax 102 bx 41000C cx C3F21394 dx
C3F2
1394
(C:\USR\SRC\PIPER\RPRD.EXE 1005) exception: si 410078 di FFFFFFFF bp 1 sp
253F03
C
(C:\USR\SRC\PIPER\RPRD.EXE 1005) exception is: STATUS_ACCESS_VIOLATION
(C:\USR\SRC\PIPER\RPRD.EXE 1005) Stack trace:
(C:\USR\SRC\PIPER\RPRD.EXE 1005) frame 0: sp = 0x253EE54, pc = 0x10007BB2
(C:\USR\SRC\PIPER\RPRD.EXE 1005) frame 1: sp = 0x253EE70, pc = 0xBFF7663C
(C:\USR\SRC\PIPER\RPRD.EXE 1005) frame 2: sp = 0x253EE94, pc = 0xBFF859D9
(C:\USR\SRC\PIPER\RPRD.EXE 1005) frame 3: sp = 0x253EF2C, pc = 0xFFECBAD7
(C:\USR\SRC\PIPER\RPRD.EXE 1005) In cygwin_except_handler exc C0000005 at
100073
A2 sp 253EE4C
(C:\USR\SRC\PIPER\RPRD.EXE 1005) Error while dumping state (probably corrupted
s
tack)
//===================================================
____________________________________________________________
Colman Curtin					mailto:ccurtin@trintech.ie
Senior Software Engineer
------------------------------------------------------------
Trintech (Manufacturing) Ltd,		http://www.trintech.com/
South County Business Park,
Leopardstown,
Dublin 18.
Tel +353-1-2956766		Fax +353-1-2954735
------------------------------------------------------------

How do you explain school to a higher intelligence?
		-- Elliot, "E.T."





-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]