sockets under ESIX Rev. D - beginner's question

Jan Hinnerk Haul pirx at wedel.hanse.de
Tue Nov 27 07:43:14 AEST 1990


I'm at the end of my wits, so methinks I should ask the gurus...

Just beginning to play with sockets (wanting to build a multi-machine
chat program), I receive core dumps in listen().

The code below is not mine; I changed only some #include directives
(ESIX has the network stuff in /usr/include/lan) and inserted one or
two printfs. The main() is mine, of course.

The code belows cores in listen(). Here it goes:

/* SOCKET.C
**
** Written by Steven Grimm (koreth at ebay.sun.com) on 11-26-87
*/

/*
** some #include changed foe ESIX Rev D. JHH
*/

#include <sys/types.h>
#include <sys/time.h>
#include <lan/net_types.h>
#include <lan/socket.h>
#include <lan/in.h>
#include <lan/inet.h>
#include <lan/netdb.h>
#include <stdio.h>
#include <ctype.h>


extern int errno;


int serversock(port)
int port;
{
	int	sock, x;
	struct	sockaddr_in server;

	sock = socket(AF_INET, SOCK_STREAM, 0);
	if (sock < 0)
		return -errno;

	memset(&server, 0, sizeof(server));
	server.sin_family = (short) AF_INET;
	server.sin_addr.s_addr = (ulong) INADDR_ANY;
	server.sin_port = (ushort) htons(port);

	x = bind(sock, &server, sizeof(server));
	if (x < 0)
	{
		close(sock);
		return -errno;
	}

	printf("socket created: port= %x \n", server.sin_port);

	listen(sock, 5);	/* CODE DUMPS HERE IN listen(3,5) */

	return sock;
}



main()
{
	int Socke;
	char puffer[1024];

	Socke=serversock(0x1234);
	if (Socke<0) exit (1);

	exit(0);
}



sdb points out:

Script started on Mon Nov 26 20:25:55 1990
$ cc -g -o sockquestion sockquestion.c -lbsd -lnet -lnsl_s
$ sockquestion
socket created: port= 3412 
Bus error - core dumped
$ sdb sockquestion
sock_strm.c: No such file or directory
0x43a in listen:No lines in file
*t
listen(3,5)   [sock_strm.c]
serversock(port=4660)   [sockquestion.c:48]
main(1,0x7ffffe94,0x7ffffe9c)   [sockquestion.c:60]
*q
$ 
script done on Mon Nov 26 20:28:59 1990


Now I'm quite lost. The code of socket.c is reported to work, and a
friend of mine with some socket knowledge (he hacked unix-domain sockets
into the xenix/286 kernel :-) does not se an error in the above code.

Oh well, it's ESIX SysV/386 Rev. D, 386, 8MB RAM, all network daemons up
and running (besides sendmail - smail 3.1 suffices for my needs), a
3C503 ethernet board installed (but nothing connected to it) and recocnized
by the kernel.

So what's going on here?

Any help would be appreciated - but please do not send me long mails, I
have to pay for them :-(

Best regards
Jan



-->
Jan Hinnerk Haul		Hinter jedem guten Paradoxon steckt ein Kreter -
+49 4103 15427 voice		und wenn er noch so kurze Beine hat. DRH



More information about the Comp.unix.sysv386 mailing list