示例#1
0
//---------------------------------------------------------------------------
void PacketFile::atClose(void)
{
	if(isOpen() && fileMode != READ)								// update filesize
	{
		int32_t endPtr = getLength();
		//seek(sizeof(int32_t));								//Move Past Version Marker
		//writeLong(endPtr);								//Write File length
		int32_t tableEntry;
		currentPacket = numPackets;
		if(!seekTable)
		{
			while(--currentPacket >= 0)
			{
				seek(TABLE_ENTRY(currentPacket));
				tableEntry = readLong();
				if(GetPacketType(tableEntry) == STORAGE_TYPE_NUL)
				{
					seek(TABLE_ENTRY(currentPacket));
					writeLong(SetPacketType(endPtr, STORAGE_TYPE_NUL));
				}
				else
				{
					endPtr = GetPacketOffset(tableEntry);
				}
			}
		}
		else
		{
			while(--currentPacket >= 0)
			{
				tableEntry = seekTable[currentPacket];
				if(GetPacketType(tableEntry) == STORAGE_TYPE_NUL)
				{
					seekTable[currentPacket] = SetPacketType(endPtr, STORAGE_TYPE_NUL);
				}
				else
				{
					endPtr = GetPacketOffset(tableEntry);
				}
			}
		}
		//-----------------------------------------------------
		// If seekTable was being used, write it back to file
		if(seekTable)
		{
			seek(sizeof(int32_t) * 2);							//File Version & File Length
			write(puint8_t(seekTable), (numPackets * sizeof(int32_t)));
		}
		//------------------------------------------------------
		// Is we were using a checkSum, calc it and write it to
		// the beginning of the file.
		if(usesCheckSum)
		{
			int32_t checkSum = checkSumFile();
			seek(0);
			writeLong(checkSum);
		}
	}
	clear();
}
示例#2
0
文件: Packet.cpp 项目: kricnam/lscman
CString CPacket::GetTime()
{
	CString str;
	if (GetPacketType()==TYPE_GROUP)
	{
		str = strData.Mid(82,5);
	}
	return str;
}
示例#3
0
文件: Packet.cpp 项目: kricnam/lscman
CString CPacket::GetDate()
{
	CString str;
	if (GetPacketType()==TYPE_GROUP)
	{
		str = strData.Mid(69,10);
	}
	return str;
}
示例#4
0
文件: Packet.cpp 项目: kricnam/lscman
CString CPacket::GetMYNo()
{
	CString str;
	if (GetPacketType()==TYPE_GROUP)
	{
		str = strData.Mid(3,2);
	}
	return str;
}
示例#5
0
文件: Packet.cpp 项目: kricnam/lscman
CString CPacket::GetSpetrumData()
{
	CString str;
	if (GetPacketType()==TYPE_SPECTRUM)
	{
		str = strData.Mid(3,strData.GetLength()-6);
	}
	return str;
}
示例#6
0
文件: Packet.cpp 项目: kricnam/lscman
CString CPacket::GetDMPData()
{
	CString str;
	if (GetPacketType()==TYPE_DATA)
	{
		str = strData.Mid(3,strData.GetLength()-6);
	}
	return str;
}
示例#7
0
文件: Packet.cpp 项目: kricnam/lscman
CString CPacket::GetTitleData()
{
	CString str;
	if (GetPacketType()==TYPE_TITLE)
	{
		str = strData.Mid(3,strData.GetLength()-6);
	}
	return str;
}
示例#8
0
文件: Packet.cpp 项目: kricnam/lscman
CString CPacket::GetGroupData()
{
	CString str;
	if (GetPacketType()==TYPE_GROUP)
	{
		str = strData.Mid(3,strData.GetLength()-6);
	}
	return str;
}
示例#9
0
    bool JackNetMasterInterface::Init()
    {
        jack_log("JackNetMasterInterface::Init : ID %u", fParams.fID);

        session_params_t host_params;
        uint attempt = 0;
        int rx_bytes = 0;

        // socket
        if (fSocket.NewSocket() == SOCKET_ERROR) {
            jack_error("Can't create socket : %s", StrError(NET_ERROR_CODE));
            return false;
        }

        // timeout on receive (for init)
        if (fSocket.SetTimeOut(MASTER_INIT_TIMEOUT) < 0) {
            jack_error("Can't set init timeout : %s", StrError(NET_ERROR_CODE));
        }

        // connect
        if (fSocket.Connect() == SOCKET_ERROR) {
            jack_error("Can't connect : %s", StrError(NET_ERROR_CODE));
            return false;
        }

        // send 'SLAVE_SETUP' until 'START_MASTER' received
        jack_info("Sending parameters to %s...", fParams.fSlaveNetName);
        do
        {
            session_params_t net_params;
            memset(&net_params, 0, sizeof(session_params_t));
            SetPacketType(&fParams, SLAVE_SETUP);
            SessionParamsHToN(&fParams, &net_params);

            if (fSocket.Send(&net_params, sizeof(session_params_t), 0) == SOCKET_ERROR) {
                jack_error("Error in send : %s", StrError(NET_ERROR_CODE));
            }

            memset(&net_params, 0, sizeof(session_params_t));
            if (((rx_bytes = fSocket.Recv(&net_params, sizeof(session_params_t), 0)) == SOCKET_ERROR) && (fSocket.GetError() != NET_NO_DATA)) {
                jack_error("Problem with network");
                return false;
            }

            SessionParamsNToH(&net_params, &host_params);
        }
        while ((GetPacketType(&host_params) != START_MASTER) && (++attempt < SLAVE_SETUP_RETRY));
        
        if (attempt == SLAVE_SETUP_RETRY) {
            jack_error("Slave doesn't respond, exiting");
            return false;
        }

        return true;
    }
示例#10
0
//---------------------------------------------------------------------------
int32_t PacketFile::readPacketOffset(int32_t packet, int32_t* lastType)
{
	int32_t offset = -1;
	if(packet < numPackets)
	{
		if(seekTable)
			offset = seekTable[packet];
		if(lastType)
			*lastType = GetPacketType(offset);
		offset = GetPacketOffset(offset);
	}
	return offset;
}
示例#11
0
//---------------------------------------------------------------------------
long PacketFile::readPacketOffset (long packet, long *lastType)
{
	long offset = -1;

	if (packet < numPackets)
	{
		if (seekTable)
			offset = seekTable[packet];

		if (lastType)
			*lastType = GetPacketType(offset);

		offset = GetPacketOffset(offset);
	}

	return offset;
}
示例#12
0
/**
 * Socket incoming data signal handler
 * use for audio, control and timing socket
 */
void MythRAOPConnection::udpDataReady(QByteArray buf, QHostAddress peer,
                                      quint16 port)
{
    // restart the idle timer
    if (m_watchdogTimer)
        m_watchdogTimer->start(10000);

    if (!m_audio || !m_codec || !m_codeccontext)
        return;

    uint8_t  type;
    uint16_t seq;
    uint64_t timestamp;

    if (!GetPacketType(buf, type, seq, timestamp))
    {
        LOG(VB_GENERAL, LOG_DEBUG, LOC +
            QString("Packet doesn't start with valid Rtp Header (0x%1)")
            .arg((uint8_t)buf[0], 0, 16));
        return;
    }

    switch (type)
    {
        case SYNC:
        case FIRSTSYNC:
            ProcessSync(buf);
            ProcessAudio();
            return;

        case FIRSTAUDIO_DATA:
            m_nextSequence  = seq;
            m_nextTimestamp = timestamp;
            // With iTunes we know what the first sequence is going to be.
            // iOS device do not tell us before streaming start what the first
            // packet is going to be.
            m_streamingStarted = true;
            break;

        case AUDIO_DATA:
        case AUDIO_RESEND:
            break;

        case TIMING_RESPONSE:
            ProcessTimeResponse(buf);
            return;

        default:
            LOG(VB_GENERAL, LOG_DEBUG, LOC +
                QString("Packet type (0x%1) not handled")
                .arg(type, 0, 16));
            return;
    }

    timestamp = framesToMs(timestamp);
    if (timestamp < m_currentTimestamp)
    {
        LOG(VB_GENERAL, LOG_DEBUG, LOC +
            QString("Received packet %1 too late, ignoring")
            .arg(seq));
        return;
    }
    // regular data packet
    if (type == AUDIO_DATA || type == FIRSTAUDIO_DATA)
    {
        if (m_streamingStarted && seq != m_nextSequence)
            SendResendRequest(timestamp, m_nextSequence, seq);

        m_nextSequence     = seq + 1;
        m_nextTimestamp    = timestamp;
        m_streamingStarted = true;
    }

    if (!m_streamingStarted)
        return;

    // resent packet
    if (type == AUDIO_RESEND)
    {
        if (m_resends.contains(seq))
        {
            LOG(VB_GENERAL, LOG_DEBUG, LOC +
                QString("Received required resend %1 (with ts:%2 last:%3)")
                .arg(seq).arg(timestamp).arg(m_nextSequence));
            m_resends.remove(seq);
        }
        else
            LOG(VB_GENERAL, LOG_WARNING, LOC +
                QString("Received unexpected resent packet %1")
                .arg(seq));
    }

    // Check that the audio packet is valid, do so by decoding it. If an error
    // occurs, ask to resend it
    QList<AudioData> *decoded = new QList<AudioData>();
    int numframes = decodeAudioPacket(type, &buf, decoded);
    if (numframes < 0)
    {
        // an error occurred, ask for the audio packet once again.
        LOG(VB_GENERAL, LOG_ERR, LOC + QString("Error decoding audio"));
        SendResendRequest(timestamp, seq, seq+1);
        return;
    }
    AudioPacket frames;
    frames.seq    = seq;
    frames.data   = decoded;
    m_audioQueue.insert(timestamp, frames);
    ProcessAudio();
}
示例#13
0
文件: Universe.cpp 项目: insolite/RPG
bool Universe::Run()
{
	bool continueFlag; //Continue game or not
	char inPacket[256]; //Holds the input packet
	char outPacket[256]; //Holds the output packet
	int iResult; //The result of 'Receive' and 'Send'

	continueFlag = true;

	connectSocket = new ClientSocket(serverAddress, serverPort);
	printf("Connected to the server\n");
	CreatePacket(outPacket, LogIn, "%s%s", login, password);
	connectSocket->Send(outPacket);

	game = NULL;
	currentCharacter = NULL;
	
	ClientGUIInit();

	//variables for camera
	cameraY = 50.0f;
	ISceneNode* camPos=render->smgr->addEmptySceneNode();
	camPos->setPosition(vector3df(50.0f,cameraY,10.0f));
	camera=render->smgr->addCameraSceneNode(NULL, vector3df(50.0f, 50.0f, 10.0f), vector3df(50.0f, 0.0f, 40.0f));

	scene::ISceneNode* lnode; 
	lnode = render->smgr->addLightSceneNode(NULL, camPos->getPosition(), video::SColorf(1.0f, 1.0f, 1.0f, 1.0f), 800.0f);
	render->smgr->setAmbientLight(video::SColor(0, 60, 60, 60));
	
	state = Continue;

	int lastUpdate = render->device->getTimer()->getTime();

	while (render->device->run() && state == Continue)
	{
		//Receving packet from the server
		iResult = connectSocket->Receive(inPacket);
		if (iResult)
		{
			if (iResult > 0)
			{ //Packet received
				switch (GetPacketType(inPacket))
				{
					case LoggedIn:
						char gameName[256];
						int locationId;
						ScanPacket(inPacket, "%s%i", gameName, &locationId);
						game = new Game(gameName, Client);
						printf("Game %s initialized\n", game->name);
						currentLocation = game->data->GetLocation(locationId);
						DrawScene();
						break;
					case NPCSpawned:
						currentLocation->SpawnNPC(new CurrentNPC(inPacket));
						break;
					case StaticSpawned:
					{
						CurrentStatic* currentStatic = new CurrentStatic(inPacket);
						currentLocation->SpawnStatic(currentStatic);
						break;
					}
					case ItemSpawned:
						char spawnType; //TODO: SpawnType as char
						ScanPacket(inPacket, "%i%i%f%f%b", NULL, NULL, NULL, NULL, &spawnType);
						switch(spawnType)
						{
							case Ground:
								currentLocation->SpawnItem(new CurrentItem(inPacket));
								break;
							case Inventory:
								currentCharacter->SpawnItem(new CurrentItem(inPacket));
								break;
						}
						break;
					case CharacterSpawned:
						if (!currentCharacter)
						{
							currentCharacter = new CurrentCharacter(inPacket);
							currentLocation->SpawnCharacter(currentCharacter);
						}
						else
						{
							currentLocation->SpawnCharacter(new CurrentCharacter(inPacket));
						}
						break;
					case SkillSpawned:
						currentCharacter->SpawnSkill(new CurrentSkill(inPacket));
						break;
					case NPCUnspawned:
						currentLocation->UnSpawnNPC(currentLocation->GetNPC(PacketGetInt(inPacket, 1)));
						break;
					case StaticUnspawned:
						currentLocation->UnSpawnStatic(currentLocation->GetStatic(PacketGetInt(inPacket, 1)));
						break;
					case ItemUnspawned:
						switch(PacketGetByte(inPacket, 5))
						{
							case Ground:
								currentLocation->UnSpawnItem(currentLocation->GetItem(PacketGetInt(inPacket, 1)));
								break;
							case Inventory:
								//currentCharacter->UnSpawnItem(currentCharacter->GetItem(PacketGetInt(inPacket, 1)));
								break;
						}
						break;
					case CharacterUnspawned:
						currentLocation->UnSpawnCharacter(currentLocation->GetCharacter(PacketGetInt(inPacket, 1)));
						break;
					case Say:
					{
						IGUIElement* eb = guienv->getRootGUIElement()->getElementFromId(ChatBox)->getElementFromId(ChatEditBox);
						char messageType; //TODO: MessageType as char
						int senderCurrentCharacterId;
						wchar_t messageText[CHAT_MESSAGE_MAX_LENGTH];
						ScanPacket(inPacket, "%b%i%ws", &messageType, &senderCurrentCharacterId, messageText);
						CurrentCharacter* sender = game->data->GetCharacter(senderCurrentCharacterId);
						
						wchar_t wLogin[64];
						mbstowcs(wLogin, sender->login, 63);
						
						int offset = wcslen(eb->getText()) + wcslen(wLogin) + wcslen(messageText) + 3 - (CHAT_MAX_LENGTH - 1);
						if (offset < 0)
							offset = 0;
						else if (offset >= CHAT_MAX_LENGTH)
							offset = CHAT_MAX_LENGTH - 1;

						wchar_t wstr[CHAT_MAX_LENGTH];
						swprintf(wstr, L"%ls\n%ls: %ls", eb->getText() + offset, wLogin, messageText);
						eb->setText(wstr);
						//delete wstr;
						break;
					}
					case CharacterMoving:
					{
						int currentCharacterId;
						f32 x, y;
						ScanPacket(inPacket, "%i%f%f", &currentCharacterId, &x, &y);
						CurrentCharacter* movingCurrentCharacter = currentLocation->GetCharacter(currentCharacterId);
						movingCurrentCharacter->setAnimation(EMAT_RUN);
						render->moveNode(movingCurrentCharacter->node, vector3df(x * CELL_SIZE, 0, y * CELL_SIZE), movingCurrentCharacter->base->speed);
						//TEST
						movingCurrentCharacter->x = x;
						movingCurrentCharacter->y = y;
						break;
					}
					case HpChanged:
					{
						int characterId, changedHp;
						CurrentCharacter *character;
						ScanPacket(inPacket, "%i%i", &characterId, &changedHp);

						if (character = currentLocation->GetCharacter(characterId))
							character->hp = changedHp;
						
						break;

					}
					case CharacterDied:
					{
						//okay	
						break;
					}
					case CharacterMoved:
					{
						int characterId;
						f32 whereX, whereY;

						ScanPacket(inPacket, "%i%f%f", &characterId, &whereX, &whereY);

						printf("CLIENT CHAR ID: %d\n", characterId);
						printf("CLIENT WHERE X: %.f\n", whereX);
						printf("CLIENT WHERE Y: %.f\n", whereY);
						CurrentCharacter *character = currentLocation->GetCharacter(characterId);

						if (character)
						{
							printf("CLIENT TEST 1\n");
							
							//character->node->setPosition(vector3df(whereX * CELL_SIZE, character->node->getPosition().Y, whereY * CELL_SIZE)); //TODO: Why setPosition is not working?!!
							render->moveNode(character->node, vector3df(whereX * CELL_SIZE, character->node->getPosition().Y, whereY * CELL_SIZE), 1000000.0f);

							printf("CLIENT TEST 2\n");
							character->x = whereX;
							character->y = whereY;
						}

						break;
					}
					case DialogOpened:
					{
						char title[256];
						char text[4096];
						wchar_t wstr[512];

						//npcID = PacketGetInt(inPacket, 1);
						//strcpy(title, PacketGetString(inPacket, 5));
						sprintf(title, "[%d] %s", PacketGetInt(inPacket, 1), PacketGetString(inPacket, 5));
						strcpy(text, PacketGetString(inPacket, strlen(PacketGetString(inPacket, 5)) + 5 + 1));

						mbstowcs(wstr, title, 255);
						IGUIWindow* wnd = guienv->addWindow(rect<s32>(256, 128, 256 + 256, 128 + 320), false, wstr, NULL, -1);
						
						char patterns[][256] = {
							"<p\\s+rect\\s*=\\s*\\\"(.*?);(.*?);(.*?);(.*?)\\\">(.*?)</p>",
							"<button\\s+rect\\s*=\\s*\\\"(.*?);(.*?);(.*?);(.*?)\\\"\\s+onclick\\s*=\\s*\\\"(.*?)\\\">(.*?)</button>",
							/*
							"<p>(.*?)</p>",
							"<p>(.*?)</p>",
							"<p>(.*?)</p>",*/
							};
						char** result;
						int patternsCount = 2;
						const char *error;
						int erroffset;
						int count;
						int ovector[30];
						
						const unsigned char *tables = NULL;
						tables = pcre_maketables();

						for (int i = 0; i < patternsCount; i++)
						{
							pcre *re = pcre_compile ((char*)patterns[i], 0, &error, &erroffset, NULL);
							count = pcre_exec(re, NULL, (char*)text, strlen(text), 0, NULL, ovector, 30);
							if (count > 0)
							{
								result = new char*[count];
								for (int c = 0; c < 2 * count; c += 2)
								{
									if (ovector[c] >= 0)
									{
										result[c / 2] = new char[ovector[c + 1] - ovector[c] + 1];
										memcpy(result[c / 2], text + ovector[c], ovector[c + 1] - ovector[c]);
										result[c / 2][ovector[c + 1] - ovector[c]] = '\0';
										//printf("%d, %d\n", ovector[c], ovector[c + 1]);
										//printf("%s\n", result[c / 2]);
									}
									else
									{
										result[c / 2] = NULL;
									}
								}

								switch (i)
								{
									case 0: //p
									{
										wchar_t wstr[1024];
										mbstowcs(wstr, result[5], 1023);
										guienv->addStaticText(wstr, rect<s32>(atoi(result[1]), atoi(result[2]), atoi(result[1]) + atoi(result[3]), atoi(result[2]) + atoi(result[4])), false, true, wnd, DialogElement, false);
										break;
									}
									case 1: //button
									{
										wchar_t wstr[256];
										mbstowcs(wstr, result[6], 255);
										guienv->addButton(rect<s32>(atoi(result[1]), atoi(result[2]), atoi(result[1]) + atoi(result[3]), atoi(result[2]) + atoi(result[4])), wnd, DialogElement + atoi(result[5]), wstr, NULL);
										break;
									}
								}
								
								for (int j = 0; j < count; j++)
									if (result[j])
										delete result[j];
								delete result;
							}
						}
						break;
					}
					case PlayEffect:
					{
						CurrentMapObject<MapObject>* currentMapObject;
						int currentMapObjectId = PacketGetInt(inPacket, 2);
						int skillId = PacketGetInt(inPacket, 6);
						switch (PacketGetByte(inPacket, 1))
						{
							case 0: //NPC
								currentMapObject = (CurrentMapObject<MapObject>*)currentLocation->GetNPC(currentMapObjectId);
								break;
							case 3: //Character
								currentMapObject = (CurrentMapObject<MapObject>*)currentLocation->GetCharacter(currentMapObjectId);
								break;
						}
						render->PlayEffect(currentMapObject->node, game->resources->GetSkill(skillId)->effectTextures);
						break;
					}
					case PlayAdvancedEffect:
						int skillId = PacketGetInt(inPacket, 1);
						f32 xStart = PacketGetInt(inPacket, 5) * CELL_SIZE;
						f32 yStart = PacketGetInt(inPacket, 9) * CELL_SIZE;
						f32 xEnd = PacketGetInt(inPacket, 13) * CELL_SIZE;
						f32 yEnd = PacketGetInt(inPacket, 17) * CELL_SIZE;
						render->Effect2(vector3df(xStart, 5.0f, yStart), vector3df(xEnd, 5.0f, yEnd)); //TEST
						break;
				}
			}
			else if (iResult == -1)
			{ //Disconnected from the server
				printf("Disconnected from the server\n");
				delete Universe::instance->login;
				delete Universe::instance->password;
				Universe::instance->login = NULL;
				Universe::instance->password = NULL;
				Universe::instance->state = NextLevel;
			}
			else
			{ //Wrong packet from the client
				printf("Warning! Wrong packet from server. Error code: %d\n", iResult);
			}
		}

		//Drawing

		if ((render->device->getTimer()->getTime() - lastUpdate) > 30)
		{
			lastUpdate = render->device->getTimer()->getTime();
			if (game)
			{
				if (currentCharacter)
				{
					render->Km = camPos->getPosition();
					render->Kt = camera->getTarget();
					//Kt.X = currentCharacter->x * CELL_SIZE;
					//Kt.Z = currentCharacter->y * CELL_SIZE;
					vector3df pos = currentCharacter->node->getPosition();
					render->Kt.X = pos.X;
					render->Kt.Z = pos.Z;
					render->Km.X = render->Kt.X;
					render->Km.Z = render->Kt.Z - 30;
					render->Km.Y = cameraY;

					camera->setPosition(render->Km);
					camera->setTarget(render->Kt);

					//vector3df lPos = camera->getPosition();
					vector3df lPos = currentCharacter->node->getPosition();
					lPos.Y = 15;
					//lPos.Z += 20;
					lnode->setPosition(lPos);
				}
				
				

				render->driver->beginScene(true, true, SColor(255,100,101,140));
					render->smgr->drawAll();
					guienv->drawAll();
				render->driver->endScene();
			}
		}
	}

	ClientGUIDestroy();

	delete connectSocket;
	if (game)
	{
		delete game;
		render->smgr->clear();
	}

	if (state == NextLevel)
		return false;
	return true;
}
示例#14
0
    net_status_t JackNetSlaveInterface::SendAvailableToMaster(int try_count)
    {
        jack_log("JackNetSlaveInterface::SendAvailableToMaster try_count = %d", try_count);
        // utility
        session_params_t host_params;
        int rx_bytes = 0;

        // socket
        if (fSocket.NewSocket() == SOCKET_ERROR) {
            jack_error("Fatal error : network unreachable - %s", StrError(NET_ERROR_CODE));
            return NET_SOCKET_ERROR;
        }

        if (fSocket.IsLocal(fMulticastIP)) {
            jack_info("Local IP is used...");
        } else {
            // bind the socket
            if (fSocket.Bind() == SOCKET_ERROR) {
                jack_error("Can't bind the socket : %s", StrError(NET_ERROR_CODE));
                return NET_SOCKET_ERROR;
            }
        }

        // timeout on receive (for init)
        if (fSocket.SetTimeOut(SLAVE_INIT_TIMEOUT) == SOCKET_ERROR) {
            jack_error("Can't set init timeout : %s", StrError(NET_ERROR_CODE));
        }

        // disable local loop
        if (fSocket.SetLocalLoop() == SOCKET_ERROR) {
            jack_error("Can't disable multicast loop : %s", StrError(NET_ERROR_CODE));
        }

        // send 'AVAILABLE' until 'SLAVE_SETUP' received
        jack_info("Waiting for a master...");
        
        do {
            // send 'available'
            session_params_t net_params;
            memset(&net_params, 0, sizeof(session_params_t));
            SessionParamsHToN(&fParams, &net_params);
            if (fSocket.SendTo(&net_params, sizeof(session_params_t), 0, fMulticastIP) == SOCKET_ERROR) {
                jack_error("Error in data send : %s", StrError(NET_ERROR_CODE));
            }

            // filter incoming packets : don't exit while no error is detected
            memset(&net_params, 0, sizeof(session_params_t));
            rx_bytes = fSocket.CatchHost(&net_params, sizeof(session_params_t), 0);
            SessionParamsNToH(&net_params, &host_params);
            if ((rx_bytes == SOCKET_ERROR) && (fSocket.GetError() != NET_NO_DATA)) {
                jack_error("Can't receive : %s", StrError(NET_ERROR_CODE));
                return NET_RECV_ERROR;
            }
        }
        while (strcmp(host_params.fPacketType, fParams.fPacketType) && (GetPacketType(&host_params) != SLAVE_SETUP)  && (--try_count > 0));
    
        // time out failure..
        if (try_count == 0) {
            jack_error("Time out error in connect");
            return NET_CONNECT_ERROR;
        }

        // everything is OK, copy parameters
        fParams = host_params;
     
        // connect the socket
        if (fSocket.Connect() == SOCKET_ERROR) {
            jack_error("Error in connect : %s", StrError(NET_ERROR_CODE));
            return NET_CONNECT_ERROR;
        }
        
        return NET_CONNECTED;
    }