lumpofs = BuffLittleLong(buf + 4 + 8 * LUMP_ENTITIES);
lumplen = BuffLittleLong(buf + 4 + 8 * LUMP_ENTITIES + 4);
dpsnprintf(desc, sizeof(desc), "BSPHL");
++<<<<<<< HEAD
+ }
+ else if (!memcmp(buf, "BSP2", 4))
+ {
+ lumpofs = BuffLittleLong(buf + 4 + 8 * LUMP_ENTITIES);
+ lumplen = BuffLittleLong(buf + 4 + 8 * LUMP_ENTITIES + 4);
+ dpsnprintf(desc, sizeof(desc), "BSP2");
+ }
+ else if (!memcmp(buf, "2PSB", 4))
+ {
+ lumpofs = BuffLittleLong(buf + 4 + 8 * LUMP_ENTITIES);
+ lumplen = BuffLittleLong(buf + 4 + 8 * LUMP_ENTITIES + 4);
++=======
+ }
+ else if (!memcmp(buf, "BSP2", 4))
+ {
+ lumpofs = BuffLittleLong(buf + 4 + 8 * LUMP_ENTITIES);
+ lumplen = BuffLittleLong(buf + 4 + 8 * LUMP_ENTITIES + 4);
+ dpsnprintf(desc, sizeof(desc), "BSP2");
+ }
+ else if (!memcmp(buf, "2PSB", 4))
+ {
+ lumpofs = BuffLittleLong(buf + 4 + 8 * LUMP_ENTITIES);
+ lumplen = BuffLittleLong(buf + 4 + 8 * LUMP_ENTITIES + 4);
++>>>>>>> origin/divVerent/lhnet_tcp
dpsnprintf(desc, sizeof(desc), "BSP2RMQe");
}
else
static int lhnet_active;
static lhnetsocket_t lhnet_socketlist;
static lhnetpacket_t lhnet_packetlist;
++<<<<<<< HEAD
+static int lhnet_default_dscp = 0;
++=======
+ static volatile int lhnet_default_dscp = 0;
++>>>>>>> origin/divVerent/lhnet_tcp
#ifdef WIN32
static int lhnet_didWSAStartup = 0;
static WSADATA lhnet_winsockdata;
#if defined(SOL_RFC1149) && defined(RFC1149_1149ONLY)
// we got reports of massive lags when this protocol was chosen as transport
// so better turn it off
++<<<<<<< HEAD
+ {
+ int rfc1149only = 0;
+ int rfc1149enabled = 0;
+ if(setsockopt(lhnetsocket->inetsocket, SOL_RFC1149, RFC1149_1149ONLY, &rfc1149only))
+ Con_Printf("LHNET_OpenSocket_Connectionless: warning: setsockopt(RFC1149_1149ONLY) returned error: %s\n", LHNETPRIVATE_StrError());
+ if(setsockopt(lhnetsocket->inetsocket, SOL_RFC1149, RFC1149_ENABLED, &rfc1149enabled))
+ Con_Printf("LHNET_OpenSocket_Connectionless: warning: setsockopt(RFC1149_ENABLED) returned error: %s\n", LHNETPRIVATE_StrError());
+ }
+#endif
+
+#ifdef SUPPORTIPV6
+ if (address->addresstype == LHNETADDRESSTYPE_INET6)
++=======
++>>>>>>> origin/divVerent/lhnet_tcp
{
- namelen = sizeof(localaddress->addr.in6);
- bindresult = bind(lhnetsocket->inetsocket, &localaddress->addr.sock, namelen);
- if (bindresult != -1)
- getsockname(lhnetsocket->inetsocket, &localaddress->addr.sock, &namelen);
+ int rfc1149only = 0;
+ int rfc1149enabled = 0;
+ if(setsockopt(lhnetsocket->inetsocket, SOL_RFC1149, RFC1149_1149ONLY, &rfc1149only))
+ Con_Printf("LHNET_OpenSocket_Connectionless: warning: setsockopt(RFC1149_1149ONLY) returned error: %s\n", LHNETPRIVATE_StrError());
+ if(setsockopt(lhnetsocket->inetsocket, SOL_RFC1149, RFC1149_ENABLED, &rfc1149enabled))
+ Con_Printf("LHNET_OpenSocket_Connectionless: warning: setsockopt(RFC1149_ENABLED) returned error: %s\n", LHNETPRIVATE_StrError());
}
- else
#endif
+ if (LHNETSOCKET_TryBind(lhnetsocket, address) != -1)
{
++<<<<<<< HEAD
+ namelen = sizeof(localaddress->addr.in);
+ bindresult = bind(lhnetsocket->inetsocket, &localaddress->addr.sock, namelen);
+ if (bindresult != -1)
+ getsockname(lhnetsocket->inetsocket, &localaddress->addr.sock, &namelen);
+ }
+ if (bindresult != -1)
+ {
+ int i = 1;
+ // enable broadcast on this socket
+ setsockopt(lhnetsocket->inetsocket, SOL_SOCKET, SO_BROADCAST, (char *)&i, sizeof(i));
+#ifdef IP_TOS
+ {
+ // enable DSCP for ToS support
+ int tos = lhnet_default_dscp << 2;
+ setsockopt(lhnetsocket->inetsocket, IPPROTO_IP, IP_TOS, (char *) &tos, sizeof(tos));
+ }
+#endif
+ lhnetsocket->next = &lhnet_socketlist;
+ lhnetsocket->prev = lhnetsocket->next->prev;
+ lhnetsocket->next->prev = lhnetsocket;
+ lhnetsocket->prev->next = lhnetsocket;
++=======
+ if (LHNETSOCKET_TryConnect(lhnetsocket, peeraddress) != -1)
+ {
+ int i = 1;
+ // enable broadcast on this socket
+ setsockopt(lhnetsocket->inetsocket, SOL_SOCKET, SO_BROADCAST, (char *)&i, sizeof(i));
+ #ifdef IP_TOS
+ {
+ // enable DSCP for ToS support
+ int tos = lhnet_default_dscp << 2;
+ setsockopt(lhnetsocket->inetsocket, IPPROTO_IP, IP_TOS, (char *) &tos, sizeof(tos));
+ }
+ #endif
+ lhnetsocket->next = &lhnet_socketlist;
+ lhnetsocket->prev = lhnetsocket->next->prev;
+ lhnetsocket->next->prev = lhnetsocket;
+ lhnetsocket->prev->next = lhnetsocket;
++>>>>>>> origin/divVerent/lhnet_tcp
#ifdef WIN32
- if (ioctlsocket(lhnetsocket->inetsocket, SIO_UDP_CONNRESET, &_false) == -1)
- Con_DPrintf("LHNET_OpenSocket_Connectionless: ioctlsocket SIO_UDP_CONNRESET returned error: %s\n", LHNETPRIVATE_StrError());
+ if (ioctlsocket(lhnetsocket->inetsocket, SIO_UDP_CONNRESET, &_false) == -1)
+ Con_DPrintf("LHNET_OpenSocket_Connectionless: ioctlsocket SIO_UDP_CONNRESET returned error: %s\n", LHNETPRIVATE_StrError());
#endif
- return lhnetsocket;
+ return lhnetsocket;
+ }
+ else
+ {
+ Con_Printf("LHNET_OpenSocket_Connectionless: connect returned error: %s\n", LHNETPRIVATE_StrError());
+ }
}
else
+ {
Con_Printf("LHNET_OpenSocket_Connectionless: bind returned error: %s\n", LHNETPRIVATE_StrError());
+ }
}
#ifdef IPV6_V6ONLY
else
}
lhnetsocket_t;
- void LHNET_Init(void);
+ void LHNET_Init(void); // must be called before any other threads got spawned
void LHNET_Shutdown(void);
++<<<<<<< HEAD
+int LHNET_DefaultDSCP(int dscp); // < 0: query; >= 0: set (returns previous value)
+void LHNET_SleepUntilPacket_Microseconds(int microseconds);
+lhnetsocket_t *LHNET_OpenSocket_Connectionless(lhnetaddress_t *address);
+void LHNET_CloseSocket(lhnetsocket_t *lhnetsocket);
++=======
+ int LHNET_DefaultDSCP(int dscp); // < 0: query; >= 0: set (returns previous value); NOT thread-safe but usually does not matter (lhnet_default_dscp)
+ void LHNET_SleepUntilPacket_Microseconds(int microseconds); // must only be used from the main thread
+ lhnetsocket_t *LHNET_OpenSocket(lhnetaddress_t *address, lhnetaddress_t *peeraddress, int use_tcp, int use_blocking, int register_for_select); // thread-safe ONLY if register_for_select is false (socketlist)
+ lhnetsocket_t *LHNET_OpenSocket_Connectionless(lhnetaddress_t *address); // NOT thread-safe! (socketlist)
+ void LHNET_CloseSocket(lhnetsocket_t *lhnetsocket); // thread-safe ONLY when the socket was created with register_for_select being false (socketlist)
++>>>>>>> origin/divVerent/lhnet_tcp
lhnetaddress_t *LHNET_AddressFromSocket(lhnetsocket_t *sock);
int LHNET_Read(lhnetsocket_t *lhnetsocket, void *content, int maxcontentlength, lhnetaddress_t *address);
int LHNET_Write(lhnetsocket_t *lhnetsocket, const void *content, int contentlength, const lhnetaddress_t *address);