Hey everyone,
i have a working socket connection and want to send a stringstream. But send() does not accept stringstreams.
What would be the best way to send the stringstream?
Thank you!
Bye
crisis
Hey everyone,
i have a working socket connection and want to send a stringstream. But send() does not accept stringstreams.
What would be the best way to send the stringstream?
Thank you!
Bye
crisis
Do you want to send the actual string collected in the stringstream? Use ss.str().c_str() to get a const char*, and send that.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
thank you very much, CornedBee!
i am always not sure when its smart to convert strings to chars because i dont have much experience yet
It's never smart, just sometimes necessary. The most common necessity is when you interact with a C API, like sockets.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
And there is no C++ library for Sockets, right? Just to make sure that its correct to use the C socket library in my C++ project...
There are a few socket libraries. My personal favourite is Asio. ACE is also good, but much more of a framework - takes longer to learn.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law