2000-04-26 04:03:38 -04:00
|
|
|
#ifndef __NET_NONBLOCK_H
|
|
|
|
#define __NET_NONBLOCK_H
|
|
|
|
|
|
|
|
#include "network.h"
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
IPADDR ip; /* resolved ip addres */
|
|
|
|
int error; /* error, 0 = no error, -1 = error: */
|
|
|
|
int errlen; /* error text length */
|
|
|
|
char *errorstr; /* error string - dynamically allocated, you'll
|
|
|
|
need to free() it yourself unless it's NULL */
|
|
|
|
} RESOLVED_IP_REC;
|
|
|
|
|
2000-05-25 07:30:47 -04:00
|
|
|
typedef struct {
|
|
|
|
int namelen;
|
|
|
|
char *name;
|
|
|
|
|
|
|
|
int error;
|
|
|
|
int errlen;
|
|
|
|
char *errorstr;
|
|
|
|
} RESOLVED_NAME_REC;
|
|
|
|
|
2000-12-04 17:57:18 -05:00
|
|
|
typedef void (*NET_CALLBACK) (GIOChannel *, void *);
|
2000-05-25 07:30:47 -04:00
|
|
|
typedef void (*NET_HOST_CALLBACK) (RESOLVED_NAME_REC *, void *);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
/* nonblocking gethostbyname(), PID of the resolver child is returned. */
|
2000-12-04 17:57:18 -05:00
|
|
|
int net_gethostbyname_nonblock(const char *addr, GIOChannel *pipe);
|
2000-05-25 07:30:47 -04:00
|
|
|
/* Get host's name, call func when finished */
|
|
|
|
int net_gethostbyaddr_nonblock(IPADDR *ip, NET_HOST_CALLBACK func, void *data);
|
2000-04-26 04:03:38 -04:00
|
|
|
/* get the resolved IP address. returns -1 if some error occured with read() */
|
2000-12-04 17:57:18 -05:00
|
|
|
int net_gethostbyname_return(GIOChannel *pipe, RESOLVED_IP_REC *rec);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
/* Connect to server, call func when finished */
|
2000-12-04 17:57:18 -05:00
|
|
|
int net_connect_nonblock(const char *server, int port, const IPADDR *my_ip,
|
|
|
|
NET_CALLBACK func, void *data);
|
2000-04-26 04:03:38 -04:00
|
|
|
/* Kill the resolver child */
|
|
|
|
void net_disconnect_nonblock(int pid);
|
|
|
|
|
|
|
|
#endif
|