bool CNullModem::ServerConnect() { // check if a connection is available. clientsocket=serversocket->Accept(); if (!clientsocket) return false; Bit8u peeripbuf[16]; clientsocket->GetRemoteAddressString(peeripbuf); LOG_MSG("Serial%d: A client (%s) has connected.",(int)COMNUMBER,peeripbuf); #if SERIAL_DEBUG log_ser(dbg_aux,"Nullmodem: A client (%s) has connected.", peeripbuf); #endif /* FIXME: It would be nice if the SDL net library had a bind() call to bind only to a specific interface. * Or maybe it does... what am I missing? */ if (!nonlocal && strcmp((char*)peeripbuf,"127.0.0.1") != 0) { LOG_MSG("Serial%d: Non-localhost client (%s) dropped by nonlocal:0 policy. To accept connections from network, set nonlocal:1",(int)COMNUMBER,peeripbuf); delete clientsocket; clientsocket = NULL; return false; } clientsocket->SetSendBufferSize(256); rx_state=N_RX_IDLE; setEvent(SERIAL_POLLING_EVENT, 1); // we don't accept further connections delete serversocket; serversocket=0; // transmit the line status setRTSDTR(getRTS(), getDTR()); if (transparent) setCD(true); return true; }
bool CNullModem::ClientConnect(TCPClientSocket* newsocket) { Bit8u peernamebuf[16]; clientsocket = newsocket; if (!clientsocket->isopen) { LOG_MSG("Serial%d: Connection failed.",COMNUMBER); delete clientsocket; clientsocket=0; setCD(false); return false; } clientsocket->SetSendBufferSize(256); clientsocket->GetRemoteAddressString(peernamebuf); // transmit the line status if (!transparent) setRTSDTR(getRTS(), getDTR()); rx_state=N_RX_IDLE; LOG_MSG("Serial%d: Connected to %s",COMNUMBER,peernamebuf); setEvent(SERIAL_POLLING_EVENT, 1); setCD(true); return true; }
bool CNullModem::ServerConnect() { // check if a connection is available. clientsocket=serversocket->Accept(); if (!clientsocket) return false; Bit8u peeripbuf[16]; clientsocket->GetRemoteAddressString(peeripbuf); LOG_MSG("Serial%d: A client (%s) has connected.",COMNUMBER,peeripbuf); #if SERIAL_DEBUG log_ser(dbg_aux,"Nullmodem: A client (%s) has connected.", peeripbuf); #endif clientsocket->SetSendBufferSize(256); rx_state=N_RX_IDLE; setEvent(SERIAL_POLLING_EVENT, 1); // we don't accept further connections delete serversocket; serversocket=0; // transmit the line status setRTSDTR(getRTS(), getDTR()); if (transparent) setCD(true); return true; }
void CNullModem::setDTR(bool val) { setRTSDTR(getRTS(), val); }
void CNullModem::setRTS(bool val) { setRTSDTR(val, getDTR()); }