16

I want to create an extremely simple iPhone program that will open a telnet session on a lan-connected device and send a sequence of keystrokes. Most of the code I've seen for sockets is overwhelming and vast overkill for what I want to do:

  1. open telnet socket to IP address
  2. send ascii keystrokes

Any simple code examples out there I can play with?

4 Answers 4

23

I'd suggest you check out the Asyncsocket project:

It makes socket programming really easy; no messing with threads yourself and things happen asynchronously without much fuss.

I think there is a sample project with a client/server to get you started.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks! I'm sure this will be helpful
how effective is this working with the 3g network? im rather new to this, but ive noticed that my socket-based programs often work perfectly fine over wifi but fail over 3g, and im at a loss as to the underlying reason for this.
If you're trying to connect directly to the iPhone's ip addr, you may be thwarted by a firewall or NAT. If the iPhone is the client connecting to your server, could be just dropped packets/timeout. You should post a specific question with the details of your problem.
@AndrewPouliot Thanks. Can you recoomend on the default timeouts for select operation on sockets in iphone?
1

Do yourself a favor: go read at least first 6 chapters of this Steven's book in which you can find plenty of simple examples and many advices how to avoid common pitfalls with network programming. Without doing that you will end with a buggy, slow and incomplete client.

Comments

1

Go through this you will have to get basic idea of socket programming

http://ichuiphonedev.blogspot.in/2012/07/a-basic-idea-of-socket-programming-in.html

Comments

0

i cant repost my code here, because SO considers it spamming to repeat your answer.

check out this sample code and tutorial link. works like a charm and is really simple to implement, less than 3 minutes and you are up and going (IF you have a socket server ready).

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.