#if wxUSE_SOCKETS
#include <assert.h>
-#include <sys/ioctl.h>
#include <sys/types.h>
-#ifdef vms
+#include <netdb.h>
+#include <sys/ioctl.h>
+#ifdef __VMS__
+#define SOCK_LEN_TYP (unsigned int*)
#include <socket.h>
+struct sockaddr_un {
+ u_char sun_len; /* sockaddr len including null */
+ u_char sun_family; /* AF_UNIX */
+ char sun_path[108]; /* path name (gag) */
+};
#else
#include <sys/socket.h>
-#endif
#include <sys/un.h>
+#define SOCK_LEN_TYP (int*)
+#endif
#include <sys/time.h>
#include <netinet/in.h>
#include <arpa/inet.h>
-#include <netdb.h>
#include <errno.h>
#include <string.h>
size = sizeof(addr);
- if (getsockname(socket->m_fd, &addr, &size) < 0) {
+ if (getsockname(socket->m_fd, &addr, SOCK_LEN_TYP &size) < 0) {
socket->m_error = GSOCK_IOERR;
return NULL;
}
close(sck->m_fd);
sck->m_fd = -1;
/* sck->m_error is set in _GSocket_Output_Timeout */
- fprintf(stderr, "Blocking connect timeouts\n");
return GSOCK_TIMEDOUT;
}
else
{
- fprintf(stderr, "Blocking connect OK\n");
return GSOCK_NOERROR;
}
}
{
sck->m_error = GSOCK_WOULDBLOCK;
sck->m_establishing = TRUE;
- fprintf(stderr, "Nonblocking connect in progress\n");
return GSOCK_WOULDBLOCK;
}
sck->m_fd = -1;
sck->m_error = GSOCK_IOERR;
- fprintf(stderr, "Connect failed (generic err)\n");
return GSOCK_IOERR;
}
- fprintf(stderr, "Connect OK\n");
return GSOCK_NOERROR;
}
fromlen = sizeof(from);
MASK_SIGNAL();
- ret = recvfrom(socket->m_fd, buffer, size, 0, &from, &fromlen);
+ ret = recvfrom(socket->m_fd, buffer, size, 0, &from,
+ SOCK_LEN_TYP &fromlen);
UNMASK_SIGNAL();
if (ret == -1)
socket->m_establishing = FALSE;
len = sizeof(error);
- getsockopt(socket->m_fd, SOL_SOCKET, SO_ERROR, (void*) &error, &len);
+ getsockopt(socket->m_fd, SOL_SOCKET, SO_ERROR, (void*) &error,
+ SOCK_LEN_TYP &len);
if (error)
{
GSocketError _GAddress_Init_INET(GAddress *address)
{
- address->m_addr = (struct sockaddr *)malloc(sizeof(struct sockaddr_in));
- if (address->m_addr == NULL) {
+ address->m_len = sizeof(struct sockaddr_in);
+ address->m_addr = (struct sockaddr *)malloc(address->m_len);
+ if (address->m_addr == NULL)
+ {
address->m_error = GSOCK_MEMERR;
return GSOCK_MEMERR;
}
- address->m_len = sizeof(struct sockaddr_in);
-
address->m_family = GSOCK_INET;
address->m_realfamily = PF_INET;
((struct sockaddr_in *)address->m_addr)->sin_family = AF_INET;
- ((struct sockaddr_in *)address->m_addr)->sin_addr.s_addr = INADDR_ANY;
+ /*
+ INADDR_BROADCAST is identical to INADDR_NONE which is not defined
+ on all unices. INADDR_BROADCAST should be fine to indicate an error.
+ */
+ ((struct sockaddr_in *)address->m_addr)->sin_addr.s_addr = INADDR_BROADCAST;
return GSOCK_NOERROR;
}
/* If it is a numeric host name, convert it now */
#if defined(HAVE_INET_ATON)
- if (inet_aton(hostname, addr) == 0) {
+ if (inet_aton(hostname, addr) == 0)
+ {
#elif defined(HAVE_INET_ADDR)
/* Fix from Guillermo Rodriguez Garcia <guille@iies.es> */
- if ( (addr->s_addr = inet_addr(hostname)) == -1 ) {
+ if ( (addr->s_addr = inet_addr(hostname)) == -1 )
+ {
#else
/* Use gethostbyname by default */
- if (1) {
+ if (1)
+ {
#endif
struct in_addr *array_addr;
/* It is a real name, we solve it */
- if ((he = gethostbyname(hostname)) == NULL) {
+ if ((he = gethostbyname(hostname)) == NULL)
+ {
address->m_error = GSOCK_NOHOST;
return GSOCK_NOHOST;
}
assert(address != NULL);
CHECK_ADDRESS(address, INET, GSOCK_INVADDR);
- if (!port) {
+ if (!port)
+ {
address->m_error = GSOCK_INVPORT;
return GSOCK_INVPORT;
}
se = getservbyname(port, protocol);
if (!se) {
- if (isdigit(port[0])) {
+ if (isdigit(port[0]))
+ {
int port_int;
port_int = atoi(port);
addr = (struct sockaddr_in *)address->m_addr;
addr_buf = (char *)&(addr->sin_addr);
- he = gethostbyaddr(addr_buf, sizeof(addr->sin_addr), AF_INET);
- if (he == NULL) {
+ he = gethostbyaddr(addr_buf, sizeof(addr->sin_addr), AF_INET);
+ if (he == NULL)
+ {
address->m_error = GSOCK_NOHOST;
return GSOCK_NOHOST;
}
GSocketError _GAddress_Init_UNIX(GAddress *address)
{
+ address->m_len = sizeof(struct sockaddr_un);
address->m_addr = (struct sockaddr *)malloc(address->m_len);
- if (address->m_addr == NULL) {
+ if (address->m_addr == NULL)
+ {
address->m_error = GSOCK_MEMERR;
return GSOCK_MEMERR;
}
- address->m_len = sizeof(struct sockaddr_un);
address->m_family = GSOCK_UNIX;
address->m_realfamily = PF_UNIX;
((struct sockaddr_un *)address->m_addr)->sun_family = AF_UNIX;