Yes it is possible. For example, see this question about setting up such a server on an iOS device.
You can do a very quick test by installing a network diagnostic application - for example, I found one of them called Console Server from SikYi Chan in the App Store.
In this application, I added βserver connectionβ on port 12345 and started the server. 172.20.10.2 my Mac, in System Preferences β Network, I found that my bound IP address was 172.20.10.2 . I assumed that the iPhone was on 172.20.10.1 and did this:
% telnet 172.20.10.1 12345 Trying 172.20.10.1... Connected to 172.20.10.1. Escape character is '^]'. hello
And in the server console in the iOS application, I got:

Cupawnte
source share