-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Added timeout to send for tcp_client and tcp_client-windows #3355
base: v1.x
Are you sure you want to change the base?
Conversation
Please remove the logs and undo example changes. Also please remove the |
I made the changes. And the appveyor builds are successful |
|
||
// try to connect or throw on failure | ||
void connect(const std::string &host, int port) { | ||
// Added timeout_ms parameter (in milliseconds) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix the comment. is it for connect only? for read and write? in seconds?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed the comments.
example/example.cpp
Outdated
// Mapped Diagnostic Context (MDC) is a map that stores key-value pairs (string values) in thread | ||
// local storage. Each thread maintains its own MDC, which loggers use to append diagnostic | ||
// information to log outputs. Note: it is not supported in asynchronous mode due to its reliance on | ||
// thread-local storage. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
undo all the changes in example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, should I take the latest example from the repo.
::setsockopt(socket_, SOL_SOCKET, SO_RCVTIMEO, reinterpret_cast<char *>(&timeout), | ||
sizeof(timeout)); | ||
::setsockopt(socket_, SOL_SOCKET, SO_SNDTIMEO, reinterpret_cast<char *>(&timeout), | ||
sizeof(timeout)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i dont think it affects connect timeout. only recv and send
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it only send and recv timeout, I can do it for connect but it would be non blocking I guess. Can I proceed with that ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am confused. Isn't the connect timeout is the whole point of this pr?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have made the other changes, about the timeout in connect syscall.
|
||
// try to connect or throw on failure | ||
void connect(const std::string &host, int port) { | ||
// Added timeout_ms parameter (in milliseconds) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed the comments.
This is against the issue: "Add timeout parameter to tcp_client::connect() #2682"
I have set socket options of SO_RCVTIMEO and SO_SNDTIMEO in the connect method of tcp_client (both normal and windows) to set the timeout that was passed in the constructor. Now the struct tcp_sink_config has extra timeout_sec parameter. Now when the tcp_client::connect() times out, it also throws an error.
Please guide me this is my first PR.