Fixed support for UNIX sockets, and fixed static crt-linking for debug builds
This commit is contained in:
parent
893a04b903
commit
f8301d6ee6
@ -43,7 +43,7 @@
|
|||||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE"
|
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="3"
|
RuntimeLibrary="1"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="3"
|
WarningLevel="3"
|
||||||
Detect64BitPortabilityProblems="true"
|
Detect64BitPortabilityProblems="true"
|
||||||
@ -62,6 +62,7 @@
|
|||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies="ws2_32.lib comctl32.lib "
|
AdditionalDependencies="ws2_32.lib comctl32.lib "
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
|
GenerateManifest="false"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
TargetMachine="1"
|
TargetMachine="1"
|
||||||
@ -71,6 +72,7 @@
|
|||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManifestTool"
|
Name="VCManifestTool"
|
||||||
|
EmbedManifest="false"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXDCMakeTool"
|
Name="VCXDCMakeTool"
|
||||||
|
|||||||
@ -43,7 +43,7 @@
|
|||||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="3"
|
RuntimeLibrary="1"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="3"
|
WarningLevel="3"
|
||||||
Detect64BitPortabilityProblems="true"
|
Detect64BitPortabilityProblems="true"
|
||||||
@ -62,6 +62,7 @@
|
|||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies="d3dx9.lib d3d9.lib"
|
AdditionalDependencies="d3dx9.lib d3d9.lib"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
|
GenerateManifest="false"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
TargetMachine="1"
|
TargetMachine="1"
|
||||||
@ -71,6 +72,7 @@
|
|||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManifestTool"
|
Name="VCManifestTool"
|
||||||
|
EmbedManifest="false"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXDCMakeTool"
|
Name="VCXDCMakeTool"
|
||||||
|
|||||||
@ -11,7 +11,12 @@
|
|||||||
#include <exception>
|
#include <exception>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
|
#else
|
||||||
|
#define TCHAR char
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "track.h"
|
#include "track.h"
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,11 @@
|
|||||||
#include "data.h"
|
#include "data.h"
|
||||||
#include "network.h"
|
#include "network.h"
|
||||||
|
|
||||||
|
#ifndef REMOTE_HOST
|
||||||
|
#define REMOTE_HOST "localhost"
|
||||||
|
#endif
|
||||||
|
#define REMOTE_PORT 1338
|
||||||
|
|
||||||
using namespace sync;
|
using namespace sync;
|
||||||
|
|
||||||
class ClientDevice : public Device
|
class ClientDevice : public Device
|
||||||
@ -14,8 +19,8 @@ public:
|
|||||||
ClientDevice(const std::string &baseName, SOCKET serverSocket, Timer &timer) :
|
ClientDevice(const std::string &baseName, SOCKET serverSocket, Timer &timer) :
|
||||||
Device(baseName),
|
Device(baseName),
|
||||||
timer(timer),
|
timer(timer),
|
||||||
serverSocket(serverSocket),
|
serverRow(-1),
|
||||||
serverRow(-1)
|
serverSocket(serverSocket)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,14 +83,13 @@ bool ClientDevice::update(float row)
|
|||||||
{
|
{
|
||||||
int track, row;
|
int track, row;
|
||||||
float value;
|
float value;
|
||||||
char interp;
|
unsigned char interp;
|
||||||
|
|
||||||
recv(serverSocket, (char*)&track, sizeof(int), 0);
|
recv(serverSocket, (char*)&track, sizeof(int), 0);
|
||||||
recv(serverSocket, (char*)&row, sizeof(int), 0);
|
recv(serverSocket, (char*)&row, sizeof(int), 0);
|
||||||
recv(serverSocket, (char*)&value, sizeof(float), 0);
|
recv(serverSocket, (char*)&value, sizeof(float), 0);
|
||||||
recv(serverSocket, (char*)&interp, 1, 0);
|
recv(serverSocket, (char*)&interp, 1, 0);
|
||||||
|
|
||||||
assert(interp >= 0);
|
|
||||||
assert(interp < Track::KeyFrame::IT_COUNT);
|
assert(interp < Track::KeyFrame::IT_COUNT);
|
||||||
|
|
||||||
sync::Track &t = syncData.getTrack(track);
|
sync::Track &t = syncData.getTrack(track);
|
||||||
@ -193,11 +197,14 @@ Device *sync::createDevice(const std::string &baseName, Timer &timer)
|
|||||||
{
|
{
|
||||||
if (false == initNetwork()) return NULL;
|
if (false == initNetwork()) return NULL;
|
||||||
|
|
||||||
struct hostent *myhost = gethostbyname("localhost");
|
struct hostent *host = gethostbyname(REMOTE_HOST);
|
||||||
|
if (NULL == host) return NULL;
|
||||||
|
printf("IP address: %s\n", inet_ntoa(*(struct in_addr*)host->h_addr_list[0]));
|
||||||
|
|
||||||
struct sockaddr_in sain;
|
struct sockaddr_in sain;
|
||||||
sain.sin_family = AF_INET;
|
sain.sin_family = AF_INET;
|
||||||
sain.sin_port = htons(1338);
|
sain.sin_port = htons(REMOTE_PORT);
|
||||||
sain.sin_addr.s_addr= *( (unsigned long *)(myhost->h_addr_list[0]) );
|
sain.sin_addr.s_addr = ((struct in_addr *)(host->h_addr_list[0]))->s_addr;
|
||||||
|
|
||||||
// connect to server
|
// connect to server
|
||||||
SOCKET serverSocket = serverConnect(&sain);
|
SOCKET serverSocket = serverConnect(&sain);
|
||||||
|
|||||||
@ -4,18 +4,36 @@
|
|||||||
|
|
||||||
#include "network.h"
|
#include "network.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifndef WIN32
|
||||||
|
|
||||||
|
#include "../wifi9.h"
|
||||||
|
#include <nds/jtypes.h>
|
||||||
|
#include <dswifi9.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
bool initNetwork()
|
bool initNetwork()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
WSADATA wsaData;
|
WSADATA wsaData;
|
||||||
if (0 != WSAStartup(MAKEWORD( 2, 0 ), &wsaData)) return false;
|
if (0 != WSAStartup(MAKEWORD( 2, 0 ), &wsaData)) return false;
|
||||||
if (LOBYTE( wsaData.wVersion ) != 2 || HIBYTE( wsaData.wVersion ) != 0) return false;
|
if (LOBYTE( wsaData.wVersion ) != 2 || HIBYTE( wsaData.wVersion ) != 0) return false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// unix sockets need no init
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void closeNetwork()
|
void closeNetwork()
|
||||||
{
|
{
|
||||||
|
#ifdef WIN32
|
||||||
WSACleanup();
|
WSACleanup();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *clientGreeting = "hello, synctracker!";
|
static const char *clientGreeting = "hello, synctracker!";
|
||||||
|
|||||||
@ -5,10 +5,22 @@
|
|||||||
#ifndef NETWORK_H
|
#ifndef NETWORK_H
|
||||||
#define NETWORK_H
|
#define NETWORK_H
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
#define SOCKET int
|
||||||
|
#define INVALID_SOCKET -1
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
bool initNetwork();
|
bool initNetwork();
|
||||||
void closeNetwork();
|
void closeNetwork();
|
||||||
|
|
||||||
|
|||||||
@ -165,7 +165,7 @@
|
|||||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE"
|
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="3"
|
RuntimeLibrary="1"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="3"
|
WarningLevel="3"
|
||||||
Detect64BitPortabilityProblems="true"
|
Detect64BitPortabilityProblems="true"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user