Issue
I write a simple application that provide connection between two computers in C. I have a problem with simultaneously reading and writing in socket. I am able to check if user press any key by getch()
, but I don't know how to check if it something in socket buffer. When I use read()
function it wait until be something in socket. I wanted to check socket buffer and then use read()
, but I can't find any function/flag to check this. Maybe is different solution for this problem, perhaps use another thread to read?
Solution
You can use sys/ioctl.h
file's method ioctl
:
#include <sys/ioctl.h>
...
int count;
ioctl(fd, FIONREAD, &count);
Reference credit : This Answer
Answered By - Kushal Answer Checked By - Robin (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.