PDA

View Full Version : Very basic app with networking




sbandol
Jun 16, 2008, 04:09 PM
Hi all,

I'm not sure if this is the best place to post such a basic question , but i will try.

So , I'm trying to make an application witch will look like this
http://monicamanea.com/MainWindow.tiff

The idea is that when i will press the button "ping" the application shall send to at predefined IP a command (a simple ASCII string, "ping" in this case) . This IP corespond to a hardware that recognize this command and will answer to this with "pong".
When the application will recieve the "pong" it will put the pong.button in active state
http://monicamanea.com/ping.tiff

The communication between my application and the hardware is TCP/IP based, the hardware have a SOCKET always opened as a server and will listen all that is receiving thru the port 8000.

The program from the hardware side is already done and i cannot change it.
I already have a windows app that are doing the same , but i dont know ho to do this in Xcode.

So i have to add an action to the buttons to : when i press a button , this will open a socket (client) and will send a predefined command to predefined IP thru the port 8000. Also the application have to receive the answer from the hardware , and put the corresponding button in correct state.

I know that some of you will say to begin with very basic Cocoa learning, but i already did this and i don't have enough time to finish it to time.
I will appreciate any help from you, I know that the time of each of you are priceless but maybe some of you can even make this litle app send me the project.

If i can provide you other info about this app , please contact me.

Thank you!



sord
Jun 16, 2008, 05:56 PM
If you need a quick and dirty...I see you already have your interface, so create an AppController with 1 action (ping: ) and 2 outlets (pingButton and pongButton). Connect your outlets to your buttons and your ping button to your action.

If you used sockets in C/C++ on Windows using standard sockets API, you can reuse your code, minus the WSAStartup or whatever its called and other winsock specifics. You will need to create an NSThread to watch for response, passing the thread your AppController to enable your Pong button when response is received.

That should give you enough to google your way through it I think.