-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Socket issue #39
Comments
if you need send data immediately, call flush after sendData, or call CCTCPSocketHub::sendPacket, it will flush. |
about another issue, maybe you are right, the socket code is very new and I may rafactor them a bit |
I think there is something wrong in if(m_outBufLen + size > kCCSocketOutputBufferDefaultSize) { if flush() dose not send anything,it may occur EINPROGRESS or EAGAIN, and the socket would destroyed. I have an idea that use a list instead of m_outBufLen ,and the element of list is a single buf,when flush() dose not send anything or send part of buf,it can be sent next time.your opinion?Thanks! |
your solution is allocating more memory to hold data, so why not directly enlarge out buffer? Or, just change kCCSocketOutputBufferDefaultSize to a bigger number. However, I don't know when can a flush() fail, maybe in a terrible situation. Something must be wrong if a flush can fail. So I don't think destroy is a overreaction for flush failure. |
Hi stubma,I have some problem in the CCTCPSocket sendData and init.
I found that the socket is in nonblocking mode,so send or recieve can in main thread.
And in sendData method,it just copy the data to the socket m_outBuf, the flush() method called only if the m_outBuf is not enough,.Dose is not in-time?
and in sendData() method :
if flush() dose not send anything,it may occur EINPROGRESS or EAGAIN,so it will execute:
if(m_outBufLen + size > kCCSocketOutputBufferDefaultSize) {
destroy();
return false;
}
and the socket would destroyed,but EINPROGRESS or EAGAIN is not a really socket error,we should send data when the socket buf writable.
Another issue is CCTCPSocket init method,
When socket created,it will connect to the server,it will blocking in select for blockSec.when create socket in main thread,it will blocking main thread,why not set the blockSec to zero,and check the connect event in Scheduler?
The text was updated successfully, but these errors were encountered: