Client Server example

Hello!


I can't found any example about that in the Apple documentation. But I would like to write a SIMPLE, VERY SIMPLE client/server Asynchronous program.


Server part: a window with a Edit Text

Client part: a Edit Text and a Button



The server part must wait the connection from the client, when I launch the client, I insert a simple text (for example "hello") in the textbox, and when I press the button the data is sent to the server part and show it in the Edit Text.




I think is a good example for who want to start a develop something like that....or where I'm wrong???

Some tutorial:


h ttps://www.raywenderlich.com/188345/swift-server-tutorial-tcp-server-with-the-swiftnio-networking-framework


Ot this (it is not Swift, but…)


h ttps://stackoverflow.com/questions/35568996/socket-programming-udp-client-server-in-c

Thanks a lot for the reply! Could I use bonjour to do that? If I use bonjour is simpliest?

I've never tried, can't tell.

There really is no such thing as a simple network program. For example, your problem description completely ignores security, which isn’t something that you can reasonably do in the modern world. If you’re new to networking I recommend that you watch my WWDC 2010 presentation, Network Apps for iPhone OS, which is a good introduction to the overall topic.

If you’re just getting start a good place to look is the WiTap sample code. This shows how to set up a TCP listener on the local network, connect to that listener, and exchange messages. It’s in Objective-C, but all of the APIs it uses are easy enough to call from Swift.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
Client Server example
 
 
Q