在Objective-C中创建套接字客户端-Mac OSX [英] Creating a socket client in Objective-C - Mac OSX

查看:100
本文介绍了在Objective-C中创建套接字客户端-Mac OSX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我基本上需要在端口587上向98.136.86.109发送一些数据".如何在我的Mac应用程序的obj-c中执行此操作?

I need to basically send some "data" to 98.136.86.109 at port 587. How can I do this in obj-c in my mac app?

推荐答案

正如Yan在回答中指出的那样,您可以使用标准的BSD风格的网络API,例如socket()connect()等.但是,如果需要停留在Objective C和Foundation中,那么您正在寻找NSInputStreamNSOutputStream,它们是Cocoa的流类.但是,您不应该查看NSSocketPort,因为它专门用于分布式对象.

As Yan notes in his answer, you could use the standard BSD-style networking APIs like socket(), connect(), etc. However, if you want to stay in Objective C and Foundation, then you're looking for NSInputStream and NSOutputStream, which are the stream classes for Cocoa. You should not, however, look at NSSocketPort as that's specifically for use with Distributed Objects.

Apple的可可流编程指南简介"在这里: http ://developer.apple.com/library/ios/#documentation/cocoa/Conceptual/Streams/Streams.html

Apple's "Introduction to Stream Programming Guide for Cocoa" is here: http://developer.apple.com/library/ios/#documentation/cocoa/Conceptual/Streams/Streams.html

您应该从该文档开始,然后检查类引用,这些类引用具有使用NSStream及其子类的示例代码项目的指针.

You should start with that document and then check out the class references which have pointers to sample code projects which use NSStream and its subclasses.

这篇关于在Objective-C中创建套接字客户端-Mac OSX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆