Ok I have done a whole ton of research and I made a little headway. Now the only problem is that it will not receive data. Here is my code. Keep in mind count is initialized to {0,0} and I tried other values.
Code:
while(recent != 'x')
{
if(_kbhit())
{
kbhit = _getch();
send(m_socket, &kbhit, 1, 0);
}
if(select(0, &ReadFDs, 0, 0, &count) > 0)
{
if(FD_ISSET(m_socket, &ReadFDs))
{
bytesRecv = recv( m_socket, &recent, 1, 0 );
cout << "Bytes Received: " << bytesRecv << " Data: " << recent << endl;
}
}
}
|: REVISION
Alright well I fixed my problem - now I have this..
Code:
while(recent != 'x')
{
if(_kbhit())
{
kbhit = _getch();
send(m_socket, &kbhit, 1, 0);
}
FD_SET(m_socket, &ReadFDs);
if(select(0, &ReadFDs, 0, 0, &count) > 0)
{
if(FD_ISSET(m_socket, &ReadFDs))
{
bytesRecv = recv( m_socket, &recent, 1, 0 );
cout << "Bytes Received: " << bytesRecv << " Data: " << recent << endl;
}
}
}
But is it really necessary to use FD_SET every loop? Why does it act as such - or is that the requirement?