swiftsocket / SwiftSocket

The easy way to use sockets on Apple platforms
BSD 3-Clause "New" or "Revised" License
1.68k stars 400 forks source link

Losing Connect #183

Open bbabbitt opened 5 years ago

bbabbitt commented 5 years ago

I finally figured out how to incorporate the SwiftSocket CocoaPod with my application. I only need a TCP Client, and If I use the Example code I can read data from my TCP Server just fine. However, the example code opens a new connection every time I request data. I need to leave the connection open and read code multiple times later. Every time I call sendRequest() I get a connection closed error message. This seems to be happening because I exit the class containing Socket calls (e.g. "Example Code"). When I go to the TCP Client to send() or read(), fd is clear (0). I am not exactly sure what fd does, but it seems to indicate a connection has been established.

How can I get around this without doing a new connection every time?

weingenious72 commented 4 years ago

@bbabbitt did you found any solution? a have also the same problem.

MartinKirkby commented 4 years ago

Hello No it was quicker to move to Streams() class in Swift than trying to fix it.

weingenious72 commented 4 years ago

Okay, thank you