[AD] Problem with Allegro (NetBSD) and socket |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
Hello,
I have a problem to report with Allegro for Unix.
I'm using at school (as a standard user) a NetBSD 1.4.2 running on PC.
Allegro was compiled using the following configuration:
./configure --enable-shared=no --enable-static=yes --enable-ossdigi=no
--enable-alsadigi=no --enable-alsamidi=no --enable-esddigi=no
--enable-ossmidi=no --enable-xwin-dga=no --enable-xwin-dga2=no
--enable-vbeaf=no --enable-svgalib=no --enable-fbcon=no --enable-vga=no
--enable-linux=no
(In short: compiled static library only, and most 'multimedia' stuff
were taken out.)
-> The problem is when using sockets on an Allegro program.
Once I open a socket (using the standard socket() function provided
with the operating system), selecting it always tells me something
has been written to the socket (=new connection) if Allegro was
initialized.
Accepting the connection (using 'accept()') blocks the program,
since there's not really an upcoming connection.
It is obviously a problem since any server program can not function
properly because of this.
The simple program below demonstrates the bug.
It can compile as is.
On my system, running it produces a result such as:
select()
New connection -> ERROR!
select()
New connection -> ERROR!
select()
New connection -> ERROR!
select()
New connection -> ERROR!
[.....]
Comment out 'allegro_init' and the error message will disappear.
Unfortunately, I am not familiar with the inners of select() to
tells whats wrong with it.
Does the Unix porters, or any Network gurus has an idea ?
Thanks a bunch for your time, and generally speaking, for Allegro.
Omar Cornut
------------------------------------------------------------------
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <netdb.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "allegro.h"
#define PORT (4260)
int fd;
fd_set fdset_in;
int main(int argc, char **argv)
{
int dum;
struct sockaddr_in host;
// Initialize Allegro
allegro_init();
// Create socket
if ((fd = socket(PF_INET, SOCK_STREAM, 0)) < 0)
{
perror("socket");
exit (1);
}
// Setup
dum = 1;
setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &dum, sizeof (dum));
host.sin_family = PF_INET;
host.sin_port = htons(PORT);
host.sin_addr.s_addr = htonl(INADDR_ANY);
// Bind
if (bind(fd, (struct sockaddr *)&host, sizeof (host)) < 0)
{
perror("bind");
exit (1);
}
// Open connections
// Note: this line is not stricly needed to reproduce the bug
listen(fd, 1);
while (1)
{
printf("select()\n");
FD_ZERO(&fdset_in);
FD_SET(fd, &fdset_in);
if (select(fd + 1, &fdset_in, NULL, NULL, NULL) == 0)
{
perror("select");
exit (1);
}
if (FD_ISSET(fd, &fdset_in))
{
printf("New connection -> ERROR!\n");
}
}
return (0);
}
END_OF_MAIN();
------------------------------------------------------------------
--
Omar Cornut [Epitech 2]
"I hate quotes at the end of e-mail" -Me