Any idea why I get these 2 messages then?
Errors:
Main Loop Code:
mnUnpauseInput(0);
// Main loop
while(mnClientConnected(0,0) == 1)
{
Sleep(1);
// Input data
iResult = mnGetInputData(0,InputData);
if(mnGetDataVolume(mnGetInputBitsPerSample(0),iResult)>50) {
mnSendUDP(0,InputData,0,false,true);
} else {
mnErase(InputData,0,sizeof(int));
}
// Packets from server
iResult = mnRecvUDP(0,RecvPacket,0,0);
if(iResult > 0) {
// Play data
int iClient = mnGetInt(RecvPacket);
mnErase(RecvPacket,0,sizeof(int));
mnPlayData(1,RecvPacket);
}
}
Full code:
#include <iostream>
#include "MikeNet.h"
#include <windows.h>
#include <climits>
using namespace std;
void main()
{
int iResult;
long long int InputData = mnCreatePacket();
long long int RecvPacket = mnCreatePacket();
// Connect to server
char IP[1024];
unsigned short Port;
cout << "Enter an IP to connect to: ";
cin >> IP;
cout << "Enter a port to connect to: ";
cin >> Port;
cout << "Connecting...\n";
mnStart(1,0);
mnSetBufferSizes(0,15000,1024,STATE_CLIENT);
iResult = mnConnect(0,IP,Port,IP,Port,5,true);
switch(iResult)
{
case(1):
cout << "Connected to server\n";
cout << "Local TCP Port: " << mnGetLocalIPTCP(0) << '\n';
cout << "Local TCP Port: " << mnGetLocalPortTCP(0) << '\n';
cout << "Local UDP IP: " << mnGetLocalIPUDP(0) << '\n';
cout << "Local UDP Port: " << mnGetLocalPortUDP(0) << '\n';
break;
case(0):
cout << "Failed to connect: timed out\n";
system("PAUSE");
return;
break;
case(-1):
cout << "Failed to connect: an unknown error occurred\n";
system("PAUSE");
return;
break;
case(-2):
cout << "Failed to connect: the server is full\n";
system("PAUSE");
return;
break;
}
// Setup sound
mnStartSound(1,mnGetMaxClients(0)+1);
mnStartInput(0,-1);
for(int n = 1;n<=mnGetMaxClients(0);n++)
{
mnStartOutput(n,-1);
}
mnUnpauseInput(0);
// Main loop
while(mnClientConnected(0,0) == 1)
{
Sleep(1);
// Input data
iResult = mnGetInputData(0,InputData);
if(mnGetDataVolume(mnGetInputBitsPerSample(0),iResult)>50) {
mnSendUDP(0,InputData,0,false,true);
} else {
mnErase(InputData,0,0);
}
// Packets from server
iResult = mnRecvUDP(0,RecvPacket,0,0);
if(iResult > 0) {
// Play data
int iClient = mnGetInt(RecvPacket);
mnErase(RecvPacket,0,sizeof(int));
mnPlayData(1,RecvPacket);
}
}
mnFinishSound();
mnFinish(-1);
return;
}
Thanks,
Alex