├── LICENSE
├── README.md
├── iOS-Socket-C-Version-Client
├── iOS-Socket-C-Version-Client.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcuserdata
│ │ │ └── huangyibiao.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── huangyibiao.xcuserdatad
│ │ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ ├── iOS-Socket-C-Version-Client.xcscheme
│ │ └── xcschememanagement.plist
├── iOS-Socket-C-Version-Client
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ │ └── AppIcon.appiconset
│ │ │ └── Contents.json
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── Info.plist
│ ├── ViewController.h
│ ├── ViewController.m
│ └── main.m
├── iOS-Socket-C-Version-ClientTests
│ ├── Info.plist
│ └── iOS_Socket_C_Version_ClientTests.m
└── iOS-Socket-C-Version-ClientUITests
│ ├── Info.plist
│ └── iOS_Socket_C_Version_ClientUITests.m
└── iOS-Socket-C-Version-Server
├── iOS-Socket-C-Version-Server.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcuserdata
│ │ └── huangyibiao.xcuserdatad
│ │ └── UserInterfaceState.xcuserstate
└── xcuserdata
│ └── huangyibiao.xcuserdatad
│ ├── xcdebugger
│ └── Breakpoints_v2.xcbkptlist
│ └── xcschemes
│ ├── iOS-Socket-C-Version-Server.xcscheme
│ └── xcschememanagement.plist
├── iOS-Socket-C-Version-Server
├── AppDelegate.h
├── AppDelegate.m
├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
├── Base.lproj
│ ├── LaunchScreen.storyboard
│ └── Main.storyboard
├── Info.plist
├── ViewController.h
├── ViewController.m
└── main.m
├── iOS-Socket-C-Version-ServerTests
├── Info.plist
└── iOS_Socket_C_Version_ServerTests.m
└── iOS-Socket-C-Version-ServerUITests
├── Info.plist
└── iOS_Socket_C_Version_ServerUITests.m
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 JackyHuang
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # iOS-Socket-C-Version
2 | 学习OC的Socket编程,本demo是基于C语言原生API的
3 |
4 | #博文讲解
5 |
6 | [iOS Socket理论知识](http://www.henishuo.com/ios-socket-theory/)
7 |
8 | [iOS Socket UDP编程-C语言版](http://www.henishuo.com/ios-socket-udp-c-version/)
9 |
10 | [iOS Socket TCP编程-C语言版](http://www.henishuo.com/ios-socket-tcp-c-version/)
11 |
12 | #关注我
13 |
14 | **微信公众号:[iOSDevShares](http://www.henishuo.com/)**
15 | **有问必答QQ群:[324400294](http://www.henishuo.com/)**
16 |
17 |
18 |
--------------------------------------------------------------------------------
/iOS-Socket-C-Version-Client/iOS-Socket-C-Version-Client.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 6961DA5E1C13E20900E7FA6D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 6961DA5D1C13E20900E7FA6D /* main.m */; };
11 | 6961DA611C13E20900E7FA6D /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6961DA601C13E20900E7FA6D /* AppDelegate.m */; };
12 | 6961DA641C13E20900E7FA6D /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6961DA631C13E20900E7FA6D /* ViewController.m */; };
13 | 6961DA671C13E20900E7FA6D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6961DA651C13E20900E7FA6D /* Main.storyboard */; };
14 | 6961DA691C13E20900E7FA6D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6961DA681C13E20900E7FA6D /* Assets.xcassets */; };
15 | 6961DA6C1C13E20900E7FA6D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6961DA6A1C13E20900E7FA6D /* LaunchScreen.storyboard */; };
16 | 6961DA771C13E20900E7FA6D /* iOS_Socket_C_Version_ClientTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6961DA761C13E20900E7FA6D /* iOS_Socket_C_Version_ClientTests.m */; };
17 | 6961DA821C13E20900E7FA6D /* iOS_Socket_C_Version_ClientUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6961DA811C13E20900E7FA6D /* iOS_Socket_C_Version_ClientUITests.m */; };
18 | /* End PBXBuildFile section */
19 |
20 | /* Begin PBXContainerItemProxy section */
21 | 6961DA731C13E20900E7FA6D /* PBXContainerItemProxy */ = {
22 | isa = PBXContainerItemProxy;
23 | containerPortal = 6961DA511C13E20900E7FA6D /* Project object */;
24 | proxyType = 1;
25 | remoteGlobalIDString = 6961DA581C13E20900E7FA6D;
26 | remoteInfo = "iOS-Socket-C-Version-Client";
27 | };
28 | 6961DA7E1C13E20900E7FA6D /* PBXContainerItemProxy */ = {
29 | isa = PBXContainerItemProxy;
30 | containerPortal = 6961DA511C13E20900E7FA6D /* Project object */;
31 | proxyType = 1;
32 | remoteGlobalIDString = 6961DA581C13E20900E7FA6D;
33 | remoteInfo = "iOS-Socket-C-Version-Client";
34 | };
35 | /* End PBXContainerItemProxy section */
36 |
37 | /* Begin PBXFileReference section */
38 | 6961DA591C13E20900E7FA6D /* iOS-Socket-C-Version-Client.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "iOS-Socket-C-Version-Client.app"; sourceTree = BUILT_PRODUCTS_DIR; };
39 | 6961DA5D1C13E20900E7FA6D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
40 | 6961DA5F1C13E20900E7FA6D /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
41 | 6961DA601C13E20900E7FA6D /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
42 | 6961DA621C13E20900E7FA6D /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; };
43 | 6961DA631C13E20900E7FA6D /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; };
44 | 6961DA661C13E20900E7FA6D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
45 | 6961DA681C13E20900E7FA6D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
46 | 6961DA6B1C13E20900E7FA6D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
47 | 6961DA6D1C13E20900E7FA6D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
48 | 6961DA721C13E20900E7FA6D /* iOS-Socket-C-Version-ClientTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "iOS-Socket-C-Version-ClientTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
49 | 6961DA761C13E20900E7FA6D /* iOS_Socket_C_Version_ClientTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = iOS_Socket_C_Version_ClientTests.m; sourceTree = ""; };
50 | 6961DA781C13E20900E7FA6D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
51 | 6961DA7D1C13E20900E7FA6D /* iOS-Socket-C-Version-ClientUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "iOS-Socket-C-Version-ClientUITests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
52 | 6961DA811C13E20900E7FA6D /* iOS_Socket_C_Version_ClientUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = iOS_Socket_C_Version_ClientUITests.m; sourceTree = ""; };
53 | 6961DA831C13E20900E7FA6D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
54 | /* End PBXFileReference section */
55 |
56 | /* Begin PBXFrameworksBuildPhase section */
57 | 6961DA561C13E20900E7FA6D /* Frameworks */ = {
58 | isa = PBXFrameworksBuildPhase;
59 | buildActionMask = 2147483647;
60 | files = (
61 | );
62 | runOnlyForDeploymentPostprocessing = 0;
63 | };
64 | 6961DA6F1C13E20900E7FA6D /* Frameworks */ = {
65 | isa = PBXFrameworksBuildPhase;
66 | buildActionMask = 2147483647;
67 | files = (
68 | );
69 | runOnlyForDeploymentPostprocessing = 0;
70 | };
71 | 6961DA7A1C13E20900E7FA6D /* Frameworks */ = {
72 | isa = PBXFrameworksBuildPhase;
73 | buildActionMask = 2147483647;
74 | files = (
75 | );
76 | runOnlyForDeploymentPostprocessing = 0;
77 | };
78 | /* End PBXFrameworksBuildPhase section */
79 |
80 | /* Begin PBXGroup section */
81 | 6961DA501C13E20900E7FA6D = {
82 | isa = PBXGroup;
83 | children = (
84 | 6961DA5B1C13E20900E7FA6D /* iOS-Socket-C-Version-Client */,
85 | 6961DA751C13E20900E7FA6D /* iOS-Socket-C-Version-ClientTests */,
86 | 6961DA801C13E20900E7FA6D /* iOS-Socket-C-Version-ClientUITests */,
87 | 6961DA5A1C13E20900E7FA6D /* Products */,
88 | );
89 | sourceTree = "";
90 | };
91 | 6961DA5A1C13E20900E7FA6D /* Products */ = {
92 | isa = PBXGroup;
93 | children = (
94 | 6961DA591C13E20900E7FA6D /* iOS-Socket-C-Version-Client.app */,
95 | 6961DA721C13E20900E7FA6D /* iOS-Socket-C-Version-ClientTests.xctest */,
96 | 6961DA7D1C13E20900E7FA6D /* iOS-Socket-C-Version-ClientUITests.xctest */,
97 | );
98 | name = Products;
99 | sourceTree = "";
100 | };
101 | 6961DA5B1C13E20900E7FA6D /* iOS-Socket-C-Version-Client */ = {
102 | isa = PBXGroup;
103 | children = (
104 | 6961DA5F1C13E20900E7FA6D /* AppDelegate.h */,
105 | 6961DA601C13E20900E7FA6D /* AppDelegate.m */,
106 | 6961DA621C13E20900E7FA6D /* ViewController.h */,
107 | 6961DA631C13E20900E7FA6D /* ViewController.m */,
108 | 6961DA651C13E20900E7FA6D /* Main.storyboard */,
109 | 6961DA681C13E20900E7FA6D /* Assets.xcassets */,
110 | 6961DA6A1C13E20900E7FA6D /* LaunchScreen.storyboard */,
111 | 6961DA6D1C13E20900E7FA6D /* Info.plist */,
112 | 6961DA5C1C13E20900E7FA6D /* Supporting Files */,
113 | );
114 | path = "iOS-Socket-C-Version-Client";
115 | sourceTree = "";
116 | };
117 | 6961DA5C1C13E20900E7FA6D /* Supporting Files */ = {
118 | isa = PBXGroup;
119 | children = (
120 | 6961DA5D1C13E20900E7FA6D /* main.m */,
121 | );
122 | name = "Supporting Files";
123 | sourceTree = "";
124 | };
125 | 6961DA751C13E20900E7FA6D /* iOS-Socket-C-Version-ClientTests */ = {
126 | isa = PBXGroup;
127 | children = (
128 | 6961DA761C13E20900E7FA6D /* iOS_Socket_C_Version_ClientTests.m */,
129 | 6961DA781C13E20900E7FA6D /* Info.plist */,
130 | );
131 | path = "iOS-Socket-C-Version-ClientTests";
132 | sourceTree = "";
133 | };
134 | 6961DA801C13E20900E7FA6D /* iOS-Socket-C-Version-ClientUITests */ = {
135 | isa = PBXGroup;
136 | children = (
137 | 6961DA811C13E20900E7FA6D /* iOS_Socket_C_Version_ClientUITests.m */,
138 | 6961DA831C13E20900E7FA6D /* Info.plist */,
139 | );
140 | path = "iOS-Socket-C-Version-ClientUITests";
141 | sourceTree = "";
142 | };
143 | /* End PBXGroup section */
144 |
145 | /* Begin PBXNativeTarget section */
146 | 6961DA581C13E20900E7FA6D /* iOS-Socket-C-Version-Client */ = {
147 | isa = PBXNativeTarget;
148 | buildConfigurationList = 6961DA861C13E20900E7FA6D /* Build configuration list for PBXNativeTarget "iOS-Socket-C-Version-Client" */;
149 | buildPhases = (
150 | 6961DA551C13E20900E7FA6D /* Sources */,
151 | 6961DA561C13E20900E7FA6D /* Frameworks */,
152 | 6961DA571C13E20900E7FA6D /* Resources */,
153 | );
154 | buildRules = (
155 | );
156 | dependencies = (
157 | );
158 | name = "iOS-Socket-C-Version-Client";
159 | productName = "iOS-Socket-C-Version-Client";
160 | productReference = 6961DA591C13E20900E7FA6D /* iOS-Socket-C-Version-Client.app */;
161 | productType = "com.apple.product-type.application";
162 | };
163 | 6961DA711C13E20900E7FA6D /* iOS-Socket-C-Version-ClientTests */ = {
164 | isa = PBXNativeTarget;
165 | buildConfigurationList = 6961DA891C13E20900E7FA6D /* Build configuration list for PBXNativeTarget "iOS-Socket-C-Version-ClientTests" */;
166 | buildPhases = (
167 | 6961DA6E1C13E20900E7FA6D /* Sources */,
168 | 6961DA6F1C13E20900E7FA6D /* Frameworks */,
169 | 6961DA701C13E20900E7FA6D /* Resources */,
170 | );
171 | buildRules = (
172 | );
173 | dependencies = (
174 | 6961DA741C13E20900E7FA6D /* PBXTargetDependency */,
175 | );
176 | name = "iOS-Socket-C-Version-ClientTests";
177 | productName = "iOS-Socket-C-Version-ClientTests";
178 | productReference = 6961DA721C13E20900E7FA6D /* iOS-Socket-C-Version-ClientTests.xctest */;
179 | productType = "com.apple.product-type.bundle.unit-test";
180 | };
181 | 6961DA7C1C13E20900E7FA6D /* iOS-Socket-C-Version-ClientUITests */ = {
182 | isa = PBXNativeTarget;
183 | buildConfigurationList = 6961DA8C1C13E20900E7FA6D /* Build configuration list for PBXNativeTarget "iOS-Socket-C-Version-ClientUITests" */;
184 | buildPhases = (
185 | 6961DA791C13E20900E7FA6D /* Sources */,
186 | 6961DA7A1C13E20900E7FA6D /* Frameworks */,
187 | 6961DA7B1C13E20900E7FA6D /* Resources */,
188 | );
189 | buildRules = (
190 | );
191 | dependencies = (
192 | 6961DA7F1C13E20900E7FA6D /* PBXTargetDependency */,
193 | );
194 | name = "iOS-Socket-C-Version-ClientUITests";
195 | productName = "iOS-Socket-C-Version-ClientUITests";
196 | productReference = 6961DA7D1C13E20900E7FA6D /* iOS-Socket-C-Version-ClientUITests.xctest */;
197 | productType = "com.apple.product-type.bundle.ui-testing";
198 | };
199 | /* End PBXNativeTarget section */
200 |
201 | /* Begin PBXProject section */
202 | 6961DA511C13E20900E7FA6D /* Project object */ = {
203 | isa = PBXProject;
204 | attributes = {
205 | LastUpgradeCheck = 0710;
206 | ORGANIZATIONNAME = huangyibiao;
207 | TargetAttributes = {
208 | 6961DA581C13E20900E7FA6D = {
209 | CreatedOnToolsVersion = 7.1;
210 | };
211 | 6961DA711C13E20900E7FA6D = {
212 | CreatedOnToolsVersion = 7.1;
213 | TestTargetID = 6961DA581C13E20900E7FA6D;
214 | };
215 | 6961DA7C1C13E20900E7FA6D = {
216 | CreatedOnToolsVersion = 7.1;
217 | TestTargetID = 6961DA581C13E20900E7FA6D;
218 | };
219 | };
220 | };
221 | buildConfigurationList = 6961DA541C13E20900E7FA6D /* Build configuration list for PBXProject "iOS-Socket-C-Version-Client" */;
222 | compatibilityVersion = "Xcode 3.2";
223 | developmentRegion = English;
224 | hasScannedForEncodings = 0;
225 | knownRegions = (
226 | en,
227 | Base,
228 | );
229 | mainGroup = 6961DA501C13E20900E7FA6D;
230 | productRefGroup = 6961DA5A1C13E20900E7FA6D /* Products */;
231 | projectDirPath = "";
232 | projectRoot = "";
233 | targets = (
234 | 6961DA581C13E20900E7FA6D /* iOS-Socket-C-Version-Client */,
235 | 6961DA711C13E20900E7FA6D /* iOS-Socket-C-Version-ClientTests */,
236 | 6961DA7C1C13E20900E7FA6D /* iOS-Socket-C-Version-ClientUITests */,
237 | );
238 | };
239 | /* End PBXProject section */
240 |
241 | /* Begin PBXResourcesBuildPhase section */
242 | 6961DA571C13E20900E7FA6D /* Resources */ = {
243 | isa = PBXResourcesBuildPhase;
244 | buildActionMask = 2147483647;
245 | files = (
246 | 6961DA6C1C13E20900E7FA6D /* LaunchScreen.storyboard in Resources */,
247 | 6961DA691C13E20900E7FA6D /* Assets.xcassets in Resources */,
248 | 6961DA671C13E20900E7FA6D /* Main.storyboard in Resources */,
249 | );
250 | runOnlyForDeploymentPostprocessing = 0;
251 | };
252 | 6961DA701C13E20900E7FA6D /* Resources */ = {
253 | isa = PBXResourcesBuildPhase;
254 | buildActionMask = 2147483647;
255 | files = (
256 | );
257 | runOnlyForDeploymentPostprocessing = 0;
258 | };
259 | 6961DA7B1C13E20900E7FA6D /* Resources */ = {
260 | isa = PBXResourcesBuildPhase;
261 | buildActionMask = 2147483647;
262 | files = (
263 | );
264 | runOnlyForDeploymentPostprocessing = 0;
265 | };
266 | /* End PBXResourcesBuildPhase section */
267 |
268 | /* Begin PBXSourcesBuildPhase section */
269 | 6961DA551C13E20900E7FA6D /* Sources */ = {
270 | isa = PBXSourcesBuildPhase;
271 | buildActionMask = 2147483647;
272 | files = (
273 | 6961DA641C13E20900E7FA6D /* ViewController.m in Sources */,
274 | 6961DA611C13E20900E7FA6D /* AppDelegate.m in Sources */,
275 | 6961DA5E1C13E20900E7FA6D /* main.m in Sources */,
276 | );
277 | runOnlyForDeploymentPostprocessing = 0;
278 | };
279 | 6961DA6E1C13E20900E7FA6D /* Sources */ = {
280 | isa = PBXSourcesBuildPhase;
281 | buildActionMask = 2147483647;
282 | files = (
283 | 6961DA771C13E20900E7FA6D /* iOS_Socket_C_Version_ClientTests.m in Sources */,
284 | );
285 | runOnlyForDeploymentPostprocessing = 0;
286 | };
287 | 6961DA791C13E20900E7FA6D /* Sources */ = {
288 | isa = PBXSourcesBuildPhase;
289 | buildActionMask = 2147483647;
290 | files = (
291 | 6961DA821C13E20900E7FA6D /* iOS_Socket_C_Version_ClientUITests.m in Sources */,
292 | );
293 | runOnlyForDeploymentPostprocessing = 0;
294 | };
295 | /* End PBXSourcesBuildPhase section */
296 |
297 | /* Begin PBXTargetDependency section */
298 | 6961DA741C13E20900E7FA6D /* PBXTargetDependency */ = {
299 | isa = PBXTargetDependency;
300 | target = 6961DA581C13E20900E7FA6D /* iOS-Socket-C-Version-Client */;
301 | targetProxy = 6961DA731C13E20900E7FA6D /* PBXContainerItemProxy */;
302 | };
303 | 6961DA7F1C13E20900E7FA6D /* PBXTargetDependency */ = {
304 | isa = PBXTargetDependency;
305 | target = 6961DA581C13E20900E7FA6D /* iOS-Socket-C-Version-Client */;
306 | targetProxy = 6961DA7E1C13E20900E7FA6D /* PBXContainerItemProxy */;
307 | };
308 | /* End PBXTargetDependency section */
309 |
310 | /* Begin PBXVariantGroup section */
311 | 6961DA651C13E20900E7FA6D /* Main.storyboard */ = {
312 | isa = PBXVariantGroup;
313 | children = (
314 | 6961DA661C13E20900E7FA6D /* Base */,
315 | );
316 | name = Main.storyboard;
317 | sourceTree = "";
318 | };
319 | 6961DA6A1C13E20900E7FA6D /* LaunchScreen.storyboard */ = {
320 | isa = PBXVariantGroup;
321 | children = (
322 | 6961DA6B1C13E20900E7FA6D /* Base */,
323 | );
324 | name = LaunchScreen.storyboard;
325 | sourceTree = "";
326 | };
327 | /* End PBXVariantGroup section */
328 |
329 | /* Begin XCBuildConfiguration section */
330 | 6961DA841C13E20900E7FA6D /* Debug */ = {
331 | isa = XCBuildConfiguration;
332 | buildSettings = {
333 | ALWAYS_SEARCH_USER_PATHS = NO;
334 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
335 | CLANG_CXX_LIBRARY = "libc++";
336 | CLANG_ENABLE_MODULES = YES;
337 | CLANG_ENABLE_OBJC_ARC = YES;
338 | CLANG_WARN_BOOL_CONVERSION = YES;
339 | CLANG_WARN_CONSTANT_CONVERSION = YES;
340 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
341 | CLANG_WARN_EMPTY_BODY = YES;
342 | CLANG_WARN_ENUM_CONVERSION = YES;
343 | CLANG_WARN_INT_CONVERSION = YES;
344 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
345 | CLANG_WARN_UNREACHABLE_CODE = YES;
346 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
347 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
348 | COPY_PHASE_STRIP = NO;
349 | DEBUG_INFORMATION_FORMAT = dwarf;
350 | ENABLE_STRICT_OBJC_MSGSEND = YES;
351 | ENABLE_TESTABILITY = YES;
352 | GCC_C_LANGUAGE_STANDARD = gnu99;
353 | GCC_DYNAMIC_NO_PIC = NO;
354 | GCC_NO_COMMON_BLOCKS = YES;
355 | GCC_OPTIMIZATION_LEVEL = 0;
356 | GCC_PREPROCESSOR_DEFINITIONS = (
357 | "DEBUG=1",
358 | "$(inherited)",
359 | );
360 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
361 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
362 | GCC_WARN_UNDECLARED_SELECTOR = YES;
363 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
364 | GCC_WARN_UNUSED_FUNCTION = YES;
365 | GCC_WARN_UNUSED_VARIABLE = YES;
366 | IPHONEOS_DEPLOYMENT_TARGET = 9.1;
367 | MTL_ENABLE_DEBUG_INFO = YES;
368 | ONLY_ACTIVE_ARCH = YES;
369 | SDKROOT = iphoneos;
370 | };
371 | name = Debug;
372 | };
373 | 6961DA851C13E20900E7FA6D /* Release */ = {
374 | isa = XCBuildConfiguration;
375 | buildSettings = {
376 | ALWAYS_SEARCH_USER_PATHS = NO;
377 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
378 | CLANG_CXX_LIBRARY = "libc++";
379 | CLANG_ENABLE_MODULES = YES;
380 | CLANG_ENABLE_OBJC_ARC = YES;
381 | CLANG_WARN_BOOL_CONVERSION = YES;
382 | CLANG_WARN_CONSTANT_CONVERSION = YES;
383 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
384 | CLANG_WARN_EMPTY_BODY = YES;
385 | CLANG_WARN_ENUM_CONVERSION = YES;
386 | CLANG_WARN_INT_CONVERSION = YES;
387 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
388 | CLANG_WARN_UNREACHABLE_CODE = YES;
389 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
390 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
391 | COPY_PHASE_STRIP = NO;
392 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
393 | ENABLE_NS_ASSERTIONS = NO;
394 | ENABLE_STRICT_OBJC_MSGSEND = YES;
395 | GCC_C_LANGUAGE_STANDARD = gnu99;
396 | GCC_NO_COMMON_BLOCKS = YES;
397 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
398 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
399 | GCC_WARN_UNDECLARED_SELECTOR = YES;
400 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
401 | GCC_WARN_UNUSED_FUNCTION = YES;
402 | GCC_WARN_UNUSED_VARIABLE = YES;
403 | IPHONEOS_DEPLOYMENT_TARGET = 9.1;
404 | MTL_ENABLE_DEBUG_INFO = NO;
405 | SDKROOT = iphoneos;
406 | VALIDATE_PRODUCT = YES;
407 | };
408 | name = Release;
409 | };
410 | 6961DA871C13E20900E7FA6D /* Debug */ = {
411 | isa = XCBuildConfiguration;
412 | buildSettings = {
413 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
414 | INFOPLIST_FILE = "iOS-Socket-C-Version-Client/Info.plist";
415 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
416 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
417 | PRODUCT_BUNDLE_IDENTIFIER = "com.huangyibiao.iOS-Socket-C-Version-Client";
418 | PRODUCT_NAME = "$(TARGET_NAME)";
419 | };
420 | name = Debug;
421 | };
422 | 6961DA881C13E20900E7FA6D /* Release */ = {
423 | isa = XCBuildConfiguration;
424 | buildSettings = {
425 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
426 | INFOPLIST_FILE = "iOS-Socket-C-Version-Client/Info.plist";
427 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
428 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
429 | PRODUCT_BUNDLE_IDENTIFIER = "com.huangyibiao.iOS-Socket-C-Version-Client";
430 | PRODUCT_NAME = "$(TARGET_NAME)";
431 | };
432 | name = Release;
433 | };
434 | 6961DA8A1C13E20900E7FA6D /* Debug */ = {
435 | isa = XCBuildConfiguration;
436 | buildSettings = {
437 | BUNDLE_LOADER = "$(TEST_HOST)";
438 | INFOPLIST_FILE = "iOS-Socket-C-Version-ClientTests/Info.plist";
439 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
440 | PRODUCT_BUNDLE_IDENTIFIER = "com.huangyibiao.iOS-Socket-C-Version-ClientTests";
441 | PRODUCT_NAME = "$(TARGET_NAME)";
442 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/iOS-Socket-C-Version-Client.app/iOS-Socket-C-Version-Client";
443 | };
444 | name = Debug;
445 | };
446 | 6961DA8B1C13E20900E7FA6D /* Release */ = {
447 | isa = XCBuildConfiguration;
448 | buildSettings = {
449 | BUNDLE_LOADER = "$(TEST_HOST)";
450 | INFOPLIST_FILE = "iOS-Socket-C-Version-ClientTests/Info.plist";
451 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
452 | PRODUCT_BUNDLE_IDENTIFIER = "com.huangyibiao.iOS-Socket-C-Version-ClientTests";
453 | PRODUCT_NAME = "$(TARGET_NAME)";
454 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/iOS-Socket-C-Version-Client.app/iOS-Socket-C-Version-Client";
455 | };
456 | name = Release;
457 | };
458 | 6961DA8D1C13E20900E7FA6D /* Debug */ = {
459 | isa = XCBuildConfiguration;
460 | buildSettings = {
461 | INFOPLIST_FILE = "iOS-Socket-C-Version-ClientUITests/Info.plist";
462 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
463 | PRODUCT_BUNDLE_IDENTIFIER = "com.huangyibiao.iOS-Socket-C-Version-ClientUITests";
464 | PRODUCT_NAME = "$(TARGET_NAME)";
465 | TEST_TARGET_NAME = "iOS-Socket-C-Version-Client";
466 | USES_XCTRUNNER = YES;
467 | };
468 | name = Debug;
469 | };
470 | 6961DA8E1C13E20900E7FA6D /* Release */ = {
471 | isa = XCBuildConfiguration;
472 | buildSettings = {
473 | INFOPLIST_FILE = "iOS-Socket-C-Version-ClientUITests/Info.plist";
474 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
475 | PRODUCT_BUNDLE_IDENTIFIER = "com.huangyibiao.iOS-Socket-C-Version-ClientUITests";
476 | PRODUCT_NAME = "$(TARGET_NAME)";
477 | TEST_TARGET_NAME = "iOS-Socket-C-Version-Client";
478 | USES_XCTRUNNER = YES;
479 | };
480 | name = Release;
481 | };
482 | /* End XCBuildConfiguration section */
483 |
484 | /* Begin XCConfigurationList section */
485 | 6961DA541C13E20900E7FA6D /* Build configuration list for PBXProject "iOS-Socket-C-Version-Client" */ = {
486 | isa = XCConfigurationList;
487 | buildConfigurations = (
488 | 6961DA841C13E20900E7FA6D /* Debug */,
489 | 6961DA851C13E20900E7FA6D /* Release */,
490 | );
491 | defaultConfigurationIsVisible = 0;
492 | defaultConfigurationName = Release;
493 | };
494 | 6961DA861C13E20900E7FA6D /* Build configuration list for PBXNativeTarget "iOS-Socket-C-Version-Client" */ = {
495 | isa = XCConfigurationList;
496 | buildConfigurations = (
497 | 6961DA871C13E20900E7FA6D /* Debug */,
498 | 6961DA881C13E20900E7FA6D /* Release */,
499 | );
500 | defaultConfigurationIsVisible = 0;
501 | };
502 | 6961DA891C13E20900E7FA6D /* Build configuration list for PBXNativeTarget "iOS-Socket-C-Version-ClientTests" */ = {
503 | isa = XCConfigurationList;
504 | buildConfigurations = (
505 | 6961DA8A1C13E20900E7FA6D /* Debug */,
506 | 6961DA8B1C13E20900E7FA6D /* Release */,
507 | );
508 | defaultConfigurationIsVisible = 0;
509 | };
510 | 6961DA8C1C13E20900E7FA6D /* Build configuration list for PBXNativeTarget "iOS-Socket-C-Version-ClientUITests" */ = {
511 | isa = XCConfigurationList;
512 | buildConfigurations = (
513 | 6961DA8D1C13E20900E7FA6D /* Debug */,
514 | 6961DA8E1C13E20900E7FA6D /* Release */,
515 | );
516 | defaultConfigurationIsVisible = 0;
517 | };
518 | /* End XCConfigurationList section */
519 | };
520 | rootObject = 6961DA511C13E20900E7FA6D /* Project object */;
521 | }
522 |
--------------------------------------------------------------------------------
/iOS-Socket-C-Version-Client/iOS-Socket-C-Version-Client.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/iOS-Socket-C-Version-Client/iOS-Socket-C-Version-Client.xcodeproj/project.xcworkspace/xcuserdata/huangyibiao.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoderJackyHuang/iOS-Socket-C-Version/d265cbcccf4fab4a5e4d2538f574fcacae87f64d/iOS-Socket-C-Version-Client/iOS-Socket-C-Version-Client.xcodeproj/project.xcworkspace/xcuserdata/huangyibiao.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/iOS-Socket-C-Version-Client/iOS-Socket-C-Version-Client.xcodeproj/xcuserdata/huangyibiao.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/iOS-Socket-C-Version-Client/iOS-Socket-C-Version-Client.xcodeproj/xcuserdata/huangyibiao.xcuserdatad/xcschemes/iOS-Socket-C-Version-Client.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
43 |
49 |
50 |
51 |
52 |
53 |
59 |
60 |
61 |
62 |
63 |
64 |
74 |
76 |
82 |
83 |
84 |
85 |
86 |
87 |
93 |
95 |
101 |
102 |
103 |
104 |
106 |
107 |
110 |
111 |
112 |
--------------------------------------------------------------------------------
/iOS-Socket-C-Version-Client/iOS-Socket-C-Version-Client.xcodeproj/xcuserdata/huangyibiao.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | iOS-Socket-C-Version-Client.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 6961DA581C13E20900E7FA6D
16 |
17 | primary
18 |
19 |
20 | 6961DA711C13E20900E7FA6D
21 |
22 | primary
23 |
24 |
25 | 6961DA7C1C13E20900E7FA6D
26 |
27 | primary
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/iOS-Socket-C-Version-Client/iOS-Socket-C-Version-Client/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // iOS-Socket-C-Version-Client
4 | //
5 | // Created by huangyibiao on 15/12/6.
6 | // Copyright © 2015年 huangyibiao. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/iOS-Socket-C-Version-Client/iOS-Socket-C-Version-Client/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // iOS-Socket-C-Version-Client
4 | //
5 | // Created by huangyibiao on 15/12/6.
6 | // Copyright © 2015年 huangyibiao. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 |
18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
19 | // Override point for customization after application launch.
20 | return YES;
21 | }
22 |
23 | - (void)applicationWillResignActive:(UIApplication *)application {
24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
26 | }
27 |
28 | - (void)applicationDidEnterBackground:(UIApplication *)application {
29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
31 | }
32 |
33 | - (void)applicationWillEnterForeground:(UIApplication *)application {
34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
35 | }
36 |
37 | - (void)applicationDidBecomeActive:(UIApplication *)application {
38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
39 | }
40 |
41 | - (void)applicationWillTerminate:(UIApplication *)application {
42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
43 | }
44 |
45 | @end
46 |
--------------------------------------------------------------------------------
/iOS-Socket-C-Version-Client/iOS-Socket-C-Version-Client/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | }
33 | ],
34 | "info" : {
35 | "version" : 1,
36 | "author" : "xcode"
37 | }
38 | }
--------------------------------------------------------------------------------
/iOS-Socket-C-Version-Client/iOS-Socket-C-Version-Client/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/iOS-Socket-C-Version-Client/iOS-Socket-C-Version-Client/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/iOS-Socket-C-Version-Client/iOS-Socket-C-Version-Client/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/iOS-Socket-C-Version-Client/iOS-Socket-C-Version-Client/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // iOS-Socket-C-Version-Client
4 | //
5 | // Created by huangyibiao on 15/12/6.
6 | // Copyright © 2015年 huangyibiao. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/iOS-Socket-C-Version-Client/iOS-Socket-C-Version-Client/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // iOS-Socket-C-Version-Client
4 | //
5 | // Created by huangyibiao on 15/12/6.
6 | // Copyright © 2015年 huangyibiao. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import
11 | #include
12 | #include
13 | #import
14 |
15 | @interface ViewController ()
16 |
17 | @end
18 |
19 | @implementation ViewController
20 |
21 | - (void)viewDidLoad {
22 | [super viewDidLoad];
23 | // Do any additional setup after loading the view, typically from a nib.
24 |
25 | // [self tcpClient];
26 | [self udpClient];
27 | }
28 |
29 | - (void)tcpClient {
30 | // 第一步:创建soket
31 | // TCP是基于数据流的,因此参数二使用SOCK_STREAM
32 | int error = -1;
33 | int clientSocketId = socket(AF_INET, SOCK_STREAM, 0);
34 | BOOL success = (clientSocketId != -1);
35 | struct sockaddr_in addr;
36 |
37 | // 第二步:绑定端口号
38 | if (success) {
39 | NSLog(@"client socket create success");
40 | // 初始化
41 | memset(&addr, 0, sizeof(addr));
42 | addr.sin_len = sizeof(addr);
43 |
44 | // 指定协议簇为AF_INET,比如TCP/UDP等
45 | addr.sin_family = AF_INET;
46 |
47 | // 监听任何ip地址
48 | addr.sin_addr.s_addr = INADDR_ANY;
49 | error = bind(clientSocketId, (const struct sockaddr *)&addr, sizeof(addr));
50 | success = (error == 0);
51 | }
52 |
53 | if (success) {
54 | // p2p
55 | struct sockaddr_in peerAddr;
56 | memset(&peerAddr, 0, sizeof(peerAddr));
57 | peerAddr.sin_len = sizeof(peerAddr);
58 | peerAddr.sin_family = AF_INET;
59 | peerAddr.sin_port = htons(1024);
60 |
61 | // 指定服务端的ip地址,测试时,修改成对应自己服务器的ip
62 | peerAddr.sin_addr.s_addr = inet_addr("192.168.1.107");
63 |
64 | socklen_t addrLen;
65 | addrLen = sizeof(peerAddr);
66 | NSLog(@"will be connecting");
67 |
68 | // 第三步:连接服务器
69 | error = connect(clientSocketId, (struct sockaddr *)&peerAddr, addrLen);
70 | success = (error == 0);
71 |
72 | if (success) {
73 | // 第四步:获取套接字信息
74 | error = getsockname(clientSocketId, (struct sockaddr *)&addr, &addrLen);
75 | success = (error == 0);
76 |
77 | if (success) {
78 | NSLog(@"client connect success, local address:%s,port:%d",
79 | inet_ntoa(addr.sin_addr),
80 | ntohs(addr.sin_port));
81 |
82 | // 这里只发送10次
83 | int count = 10;
84 | do {
85 | // 第五步:发送消息到服务端
86 | send(clientSocketId, "哈哈,server您好!", 1024, 0);
87 | count--;
88 |
89 | // 告诉server,客户端退出了
90 | if (count == 0) {
91 | send(clientSocketId, "exit", 1024, 0);
92 | }
93 | } while (count >= 1);
94 |
95 | // 第六步:关闭套接字
96 | close(clientSocketId);
97 | }
98 | } else {
99 | NSLog(@"connect failed");
100 |
101 | // 第六步:关闭套接字
102 | close(clientSocketId);
103 | }
104 | }
105 | }
106 |
107 | - (void)udpClient {
108 | int clientSocketId;
109 | ssize_t len;
110 | socklen_t addrlen;
111 | struct sockaddr_in client_sockaddr;
112 | char buffer[256] = "Hello, server, how are you?";
113 |
114 | // 第一步:创建Socket
115 | clientSocketId = socket(AF_INET, SOCK_DGRAM, 0);
116 | if(clientSocketId < 0) {
117 | NSLog(@"creat client socket fail\n");
118 | return;
119 | }
120 |
121 | addrlen = sizeof(struct sockaddr_in);
122 | bzero(&client_sockaddr, addrlen);
123 | client_sockaddr.sin_family = AF_INET;
124 | client_sockaddr.sin_addr.s_addr = inet_addr("192.168.1.107");
125 | client_sockaddr.sin_port = htons(1024);
126 |
127 | int count = 10;
128 | do {
129 | bzero(buffer, sizeof(buffer));
130 | sprintf(buffer, "%s", "Hello, server, how are you?");
131 |
132 | // 第二步:发送消息到服务端
133 | // 注意:UDP是面向无连接的,因此不用调用connect()
134 | // 将字符串传送给server端
135 | len = sendto(clientSocketId, buffer, sizeof(buffer), 0, (struct sockaddr *)&client_sockaddr, addrlen);
136 |
137 | if (len > 0) {
138 | NSLog(@"发送成功");
139 | } else {
140 | NSLog(@"发送失败");
141 | }
142 |
143 | // 第三步:接收来自服务端返回的消息
144 | // 接收server端返回的字符串
145 | bzero(buffer, sizeof(buffer));
146 | len = recvfrom(clientSocketId, buffer, sizeof(buffer), 0, (struct sockaddr *)&client_sockaddr, &addrlen);
147 | NSLog(@"receive message from server: %s", buffer);
148 |
149 | count--;
150 | } while (count >= 0);
151 |
152 | // 第四步:关闭socket
153 | // 由于是面向无连接的,消息发出处就可以了,不用管它收不收得到,发完就可以关闭了
154 | close(clientSocketId);
155 | }
156 |
157 | @end
158 |
--------------------------------------------------------------------------------
/iOS-Socket-C-Version-Client/iOS-Socket-C-Version-Client/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // iOS-Socket-C-Version-Client
4 | //
5 | // Created by huangyibiao on 15/12/6.
6 | // Copyright © 2015年 huangyibiao. All rights reserved.
7 | //
8 |
9 |
10 | #import
11 | #import "AppDelegate.h"
12 |
13 | int main(int argc, char * argv[]) {
14 | @autoreleasepool {
15 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/iOS-Socket-C-Version-Client/iOS-Socket-C-Version-ClientTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/iOS-Socket-C-Version-Client/iOS-Socket-C-Version-ClientTests/iOS_Socket_C_Version_ClientTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // iOS_Socket_C_Version_ClientTests.m
3 | // iOS-Socket-C-Version-ClientTests
4 | //
5 | // Created by huangyibiao on 15/12/6.
6 | // Copyright © 2015年 huangyibiao. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface iOS_Socket_C_Version_ClientTests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation iOS_Socket_C_Version_ClientTests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 | // Put setup code here. This method is called before the invocation of each test method in the class.
20 | }
21 |
22 | - (void)tearDown {
23 | // Put teardown code here. This method is called after the invocation of each test method in the class.
24 | [super tearDown];
25 | }
26 |
27 | - (void)testExample {
28 | // This is an example of a functional test case.
29 | // Use XCTAssert and related functions to verify your tests produce the correct results.
30 | }
31 |
32 | - (void)testPerformanceExample {
33 | // This is an example of a performance test case.
34 | [self measureBlock:^{
35 | // Put the code you want to measure the time of here.
36 | }];
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/iOS-Socket-C-Version-Client/iOS-Socket-C-Version-ClientUITests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/iOS-Socket-C-Version-Client/iOS-Socket-C-Version-ClientUITests/iOS_Socket_C_Version_ClientUITests.m:
--------------------------------------------------------------------------------
1 | //
2 | // iOS_Socket_C_Version_ClientUITests.m
3 | // iOS-Socket-C-Version-ClientUITests
4 | //
5 | // Created by huangyibiao on 15/12/6.
6 | // Copyright © 2015年 huangyibiao. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface iOS_Socket_C_Version_ClientUITests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation iOS_Socket_C_Version_ClientUITests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 |
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 |
22 | // In UI tests it is usually best to stop immediately when a failure occurs.
23 | self.continueAfterFailure = NO;
24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
25 | [[[XCUIApplication alloc] init] launch];
26 |
27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
28 | }
29 |
30 | - (void)tearDown {
31 | // Put teardown code here. This method is called after the invocation of each test method in the class.
32 | [super tearDown];
33 | }
34 |
35 | - (void)testExample {
36 | // Use recording to get started writing UI tests.
37 | // Use XCTAssert and related functions to verify your tests produce the correct results.
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/iOS-Socket-C-Version-Server/iOS-Socket-C-Version-Server.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 6961DA9D1C13E23B00E7FA6D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 6961DA9C1C13E23B00E7FA6D /* main.m */; };
11 | 6961DAA01C13E23B00E7FA6D /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6961DA9F1C13E23B00E7FA6D /* AppDelegate.m */; };
12 | 6961DAA31C13E23B00E7FA6D /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6961DAA21C13E23B00E7FA6D /* ViewController.m */; };
13 | 6961DAA61C13E23B00E7FA6D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6961DAA41C13E23B00E7FA6D /* Main.storyboard */; };
14 | 6961DAA81C13E23B00E7FA6D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6961DAA71C13E23B00E7FA6D /* Assets.xcassets */; };
15 | 6961DAAB1C13E23B00E7FA6D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6961DAA91C13E23B00E7FA6D /* LaunchScreen.storyboard */; };
16 | 6961DAB61C13E23B00E7FA6D /* iOS_Socket_C_Version_ServerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6961DAB51C13E23B00E7FA6D /* iOS_Socket_C_Version_ServerTests.m */; };
17 | 6961DAC11C13E23B00E7FA6D /* iOS_Socket_C_Version_ServerUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6961DAC01C13E23B00E7FA6D /* iOS_Socket_C_Version_ServerUITests.m */; };
18 | /* End PBXBuildFile section */
19 |
20 | /* Begin PBXContainerItemProxy section */
21 | 6961DAB21C13E23B00E7FA6D /* PBXContainerItemProxy */ = {
22 | isa = PBXContainerItemProxy;
23 | containerPortal = 6961DA901C13E23B00E7FA6D /* Project object */;
24 | proxyType = 1;
25 | remoteGlobalIDString = 6961DA971C13E23B00E7FA6D;
26 | remoteInfo = "iOS-Socket-C-Version-Server";
27 | };
28 | 6961DABD1C13E23B00E7FA6D /* PBXContainerItemProxy */ = {
29 | isa = PBXContainerItemProxy;
30 | containerPortal = 6961DA901C13E23B00E7FA6D /* Project object */;
31 | proxyType = 1;
32 | remoteGlobalIDString = 6961DA971C13E23B00E7FA6D;
33 | remoteInfo = "iOS-Socket-C-Version-Server";
34 | };
35 | /* End PBXContainerItemProxy section */
36 |
37 | /* Begin PBXFileReference section */
38 | 6961DA981C13E23B00E7FA6D /* iOS-Socket-C-Version-Server.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "iOS-Socket-C-Version-Server.app"; sourceTree = BUILT_PRODUCTS_DIR; };
39 | 6961DA9C1C13E23B00E7FA6D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
40 | 6961DA9E1C13E23B00E7FA6D /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
41 | 6961DA9F1C13E23B00E7FA6D /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
42 | 6961DAA11C13E23B00E7FA6D /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; };
43 | 6961DAA21C13E23B00E7FA6D /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; };
44 | 6961DAA51C13E23B00E7FA6D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
45 | 6961DAA71C13E23B00E7FA6D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
46 | 6961DAAA1C13E23B00E7FA6D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
47 | 6961DAAC1C13E23B00E7FA6D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
48 | 6961DAB11C13E23B00E7FA6D /* iOS-Socket-C-Version-ServerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "iOS-Socket-C-Version-ServerTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
49 | 6961DAB51C13E23B00E7FA6D /* iOS_Socket_C_Version_ServerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = iOS_Socket_C_Version_ServerTests.m; sourceTree = ""; };
50 | 6961DAB71C13E23B00E7FA6D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
51 | 6961DABC1C13E23B00E7FA6D /* iOS-Socket-C-Version-ServerUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "iOS-Socket-C-Version-ServerUITests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
52 | 6961DAC01C13E23B00E7FA6D /* iOS_Socket_C_Version_ServerUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = iOS_Socket_C_Version_ServerUITests.m; sourceTree = ""; };
53 | 6961DAC21C13E23B00E7FA6D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
54 | /* End PBXFileReference section */
55 |
56 | /* Begin PBXFrameworksBuildPhase section */
57 | 6961DA951C13E23B00E7FA6D /* Frameworks */ = {
58 | isa = PBXFrameworksBuildPhase;
59 | buildActionMask = 2147483647;
60 | files = (
61 | );
62 | runOnlyForDeploymentPostprocessing = 0;
63 | };
64 | 6961DAAE1C13E23B00E7FA6D /* Frameworks */ = {
65 | isa = PBXFrameworksBuildPhase;
66 | buildActionMask = 2147483647;
67 | files = (
68 | );
69 | runOnlyForDeploymentPostprocessing = 0;
70 | };
71 | 6961DAB91C13E23B00E7FA6D /* Frameworks */ = {
72 | isa = PBXFrameworksBuildPhase;
73 | buildActionMask = 2147483647;
74 | files = (
75 | );
76 | runOnlyForDeploymentPostprocessing = 0;
77 | };
78 | /* End PBXFrameworksBuildPhase section */
79 |
80 | /* Begin PBXGroup section */
81 | 6961DA8F1C13E23B00E7FA6D = {
82 | isa = PBXGroup;
83 | children = (
84 | 6961DA9A1C13E23B00E7FA6D /* iOS-Socket-C-Version-Server */,
85 | 6961DAB41C13E23B00E7FA6D /* iOS-Socket-C-Version-ServerTests */,
86 | 6961DABF1C13E23B00E7FA6D /* iOS-Socket-C-Version-ServerUITests */,
87 | 6961DA991C13E23B00E7FA6D /* Products */,
88 | );
89 | sourceTree = "";
90 | };
91 | 6961DA991C13E23B00E7FA6D /* Products */ = {
92 | isa = PBXGroup;
93 | children = (
94 | 6961DA981C13E23B00E7FA6D /* iOS-Socket-C-Version-Server.app */,
95 | 6961DAB11C13E23B00E7FA6D /* iOS-Socket-C-Version-ServerTests.xctest */,
96 | 6961DABC1C13E23B00E7FA6D /* iOS-Socket-C-Version-ServerUITests.xctest */,
97 | );
98 | name = Products;
99 | sourceTree = "";
100 | };
101 | 6961DA9A1C13E23B00E7FA6D /* iOS-Socket-C-Version-Server */ = {
102 | isa = PBXGroup;
103 | children = (
104 | 6961DA9E1C13E23B00E7FA6D /* AppDelegate.h */,
105 | 6961DA9F1C13E23B00E7FA6D /* AppDelegate.m */,
106 | 6961DAA11C13E23B00E7FA6D /* ViewController.h */,
107 | 6961DAA21C13E23B00E7FA6D /* ViewController.m */,
108 | 6961DAA41C13E23B00E7FA6D /* Main.storyboard */,
109 | 6961DAA71C13E23B00E7FA6D /* Assets.xcassets */,
110 | 6961DAA91C13E23B00E7FA6D /* LaunchScreen.storyboard */,
111 | 6961DAAC1C13E23B00E7FA6D /* Info.plist */,
112 | 6961DA9B1C13E23B00E7FA6D /* Supporting Files */,
113 | );
114 | path = "iOS-Socket-C-Version-Server";
115 | sourceTree = "";
116 | };
117 | 6961DA9B1C13E23B00E7FA6D /* Supporting Files */ = {
118 | isa = PBXGroup;
119 | children = (
120 | 6961DA9C1C13E23B00E7FA6D /* main.m */,
121 | );
122 | name = "Supporting Files";
123 | sourceTree = "";
124 | };
125 | 6961DAB41C13E23B00E7FA6D /* iOS-Socket-C-Version-ServerTests */ = {
126 | isa = PBXGroup;
127 | children = (
128 | 6961DAB51C13E23B00E7FA6D /* iOS_Socket_C_Version_ServerTests.m */,
129 | 6961DAB71C13E23B00E7FA6D /* Info.plist */,
130 | );
131 | path = "iOS-Socket-C-Version-ServerTests";
132 | sourceTree = "";
133 | };
134 | 6961DABF1C13E23B00E7FA6D /* iOS-Socket-C-Version-ServerUITests */ = {
135 | isa = PBXGroup;
136 | children = (
137 | 6961DAC01C13E23B00E7FA6D /* iOS_Socket_C_Version_ServerUITests.m */,
138 | 6961DAC21C13E23B00E7FA6D /* Info.plist */,
139 | );
140 | path = "iOS-Socket-C-Version-ServerUITests";
141 | sourceTree = "";
142 | };
143 | /* End PBXGroup section */
144 |
145 | /* Begin PBXNativeTarget section */
146 | 6961DA971C13E23B00E7FA6D /* iOS-Socket-C-Version-Server */ = {
147 | isa = PBXNativeTarget;
148 | buildConfigurationList = 6961DAC51C13E23B00E7FA6D /* Build configuration list for PBXNativeTarget "iOS-Socket-C-Version-Server" */;
149 | buildPhases = (
150 | 6961DA941C13E23B00E7FA6D /* Sources */,
151 | 6961DA951C13E23B00E7FA6D /* Frameworks */,
152 | 6961DA961C13E23B00E7FA6D /* Resources */,
153 | );
154 | buildRules = (
155 | );
156 | dependencies = (
157 | );
158 | name = "iOS-Socket-C-Version-Server";
159 | productName = "iOS-Socket-C-Version-Server";
160 | productReference = 6961DA981C13E23B00E7FA6D /* iOS-Socket-C-Version-Server.app */;
161 | productType = "com.apple.product-type.application";
162 | };
163 | 6961DAB01C13E23B00E7FA6D /* iOS-Socket-C-Version-ServerTests */ = {
164 | isa = PBXNativeTarget;
165 | buildConfigurationList = 6961DAC81C13E23B00E7FA6D /* Build configuration list for PBXNativeTarget "iOS-Socket-C-Version-ServerTests" */;
166 | buildPhases = (
167 | 6961DAAD1C13E23B00E7FA6D /* Sources */,
168 | 6961DAAE1C13E23B00E7FA6D /* Frameworks */,
169 | 6961DAAF1C13E23B00E7FA6D /* Resources */,
170 | );
171 | buildRules = (
172 | );
173 | dependencies = (
174 | 6961DAB31C13E23B00E7FA6D /* PBXTargetDependency */,
175 | );
176 | name = "iOS-Socket-C-Version-ServerTests";
177 | productName = "iOS-Socket-C-Version-ServerTests";
178 | productReference = 6961DAB11C13E23B00E7FA6D /* iOS-Socket-C-Version-ServerTests.xctest */;
179 | productType = "com.apple.product-type.bundle.unit-test";
180 | };
181 | 6961DABB1C13E23B00E7FA6D /* iOS-Socket-C-Version-ServerUITests */ = {
182 | isa = PBXNativeTarget;
183 | buildConfigurationList = 6961DACB1C13E23B00E7FA6D /* Build configuration list for PBXNativeTarget "iOS-Socket-C-Version-ServerUITests" */;
184 | buildPhases = (
185 | 6961DAB81C13E23B00E7FA6D /* Sources */,
186 | 6961DAB91C13E23B00E7FA6D /* Frameworks */,
187 | 6961DABA1C13E23B00E7FA6D /* Resources */,
188 | );
189 | buildRules = (
190 | );
191 | dependencies = (
192 | 6961DABE1C13E23B00E7FA6D /* PBXTargetDependency */,
193 | );
194 | name = "iOS-Socket-C-Version-ServerUITests";
195 | productName = "iOS-Socket-C-Version-ServerUITests";
196 | productReference = 6961DABC1C13E23B00E7FA6D /* iOS-Socket-C-Version-ServerUITests.xctest */;
197 | productType = "com.apple.product-type.bundle.ui-testing";
198 | };
199 | /* End PBXNativeTarget section */
200 |
201 | /* Begin PBXProject section */
202 | 6961DA901C13E23B00E7FA6D /* Project object */ = {
203 | isa = PBXProject;
204 | attributes = {
205 | LastUpgradeCheck = 0710;
206 | ORGANIZATIONNAME = huangyibiao;
207 | TargetAttributes = {
208 | 6961DA971C13E23B00E7FA6D = {
209 | CreatedOnToolsVersion = 7.1;
210 | };
211 | 6961DAB01C13E23B00E7FA6D = {
212 | CreatedOnToolsVersion = 7.1;
213 | TestTargetID = 6961DA971C13E23B00E7FA6D;
214 | };
215 | 6961DABB1C13E23B00E7FA6D = {
216 | CreatedOnToolsVersion = 7.1;
217 | TestTargetID = 6961DA971C13E23B00E7FA6D;
218 | };
219 | };
220 | };
221 | buildConfigurationList = 6961DA931C13E23B00E7FA6D /* Build configuration list for PBXProject "iOS-Socket-C-Version-Server" */;
222 | compatibilityVersion = "Xcode 3.2";
223 | developmentRegion = English;
224 | hasScannedForEncodings = 0;
225 | knownRegions = (
226 | en,
227 | Base,
228 | );
229 | mainGroup = 6961DA8F1C13E23B00E7FA6D;
230 | productRefGroup = 6961DA991C13E23B00E7FA6D /* Products */;
231 | projectDirPath = "";
232 | projectRoot = "";
233 | targets = (
234 | 6961DA971C13E23B00E7FA6D /* iOS-Socket-C-Version-Server */,
235 | 6961DAB01C13E23B00E7FA6D /* iOS-Socket-C-Version-ServerTests */,
236 | 6961DABB1C13E23B00E7FA6D /* iOS-Socket-C-Version-ServerUITests */,
237 | );
238 | };
239 | /* End PBXProject section */
240 |
241 | /* Begin PBXResourcesBuildPhase section */
242 | 6961DA961C13E23B00E7FA6D /* Resources */ = {
243 | isa = PBXResourcesBuildPhase;
244 | buildActionMask = 2147483647;
245 | files = (
246 | 6961DAAB1C13E23B00E7FA6D /* LaunchScreen.storyboard in Resources */,
247 | 6961DAA81C13E23B00E7FA6D /* Assets.xcassets in Resources */,
248 | 6961DAA61C13E23B00E7FA6D /* Main.storyboard in Resources */,
249 | );
250 | runOnlyForDeploymentPostprocessing = 0;
251 | };
252 | 6961DAAF1C13E23B00E7FA6D /* Resources */ = {
253 | isa = PBXResourcesBuildPhase;
254 | buildActionMask = 2147483647;
255 | files = (
256 | );
257 | runOnlyForDeploymentPostprocessing = 0;
258 | };
259 | 6961DABA1C13E23B00E7FA6D /* Resources */ = {
260 | isa = PBXResourcesBuildPhase;
261 | buildActionMask = 2147483647;
262 | files = (
263 | );
264 | runOnlyForDeploymentPostprocessing = 0;
265 | };
266 | /* End PBXResourcesBuildPhase section */
267 |
268 | /* Begin PBXSourcesBuildPhase section */
269 | 6961DA941C13E23B00E7FA6D /* Sources */ = {
270 | isa = PBXSourcesBuildPhase;
271 | buildActionMask = 2147483647;
272 | files = (
273 | 6961DAA31C13E23B00E7FA6D /* ViewController.m in Sources */,
274 | 6961DAA01C13E23B00E7FA6D /* AppDelegate.m in Sources */,
275 | 6961DA9D1C13E23B00E7FA6D /* main.m in Sources */,
276 | );
277 | runOnlyForDeploymentPostprocessing = 0;
278 | };
279 | 6961DAAD1C13E23B00E7FA6D /* Sources */ = {
280 | isa = PBXSourcesBuildPhase;
281 | buildActionMask = 2147483647;
282 | files = (
283 | 6961DAB61C13E23B00E7FA6D /* iOS_Socket_C_Version_ServerTests.m in Sources */,
284 | );
285 | runOnlyForDeploymentPostprocessing = 0;
286 | };
287 | 6961DAB81C13E23B00E7FA6D /* Sources */ = {
288 | isa = PBXSourcesBuildPhase;
289 | buildActionMask = 2147483647;
290 | files = (
291 | 6961DAC11C13E23B00E7FA6D /* iOS_Socket_C_Version_ServerUITests.m in Sources */,
292 | );
293 | runOnlyForDeploymentPostprocessing = 0;
294 | };
295 | /* End PBXSourcesBuildPhase section */
296 |
297 | /* Begin PBXTargetDependency section */
298 | 6961DAB31C13E23B00E7FA6D /* PBXTargetDependency */ = {
299 | isa = PBXTargetDependency;
300 | target = 6961DA971C13E23B00E7FA6D /* iOS-Socket-C-Version-Server */;
301 | targetProxy = 6961DAB21C13E23B00E7FA6D /* PBXContainerItemProxy */;
302 | };
303 | 6961DABE1C13E23B00E7FA6D /* PBXTargetDependency */ = {
304 | isa = PBXTargetDependency;
305 | target = 6961DA971C13E23B00E7FA6D /* iOS-Socket-C-Version-Server */;
306 | targetProxy = 6961DABD1C13E23B00E7FA6D /* PBXContainerItemProxy */;
307 | };
308 | /* End PBXTargetDependency section */
309 |
310 | /* Begin PBXVariantGroup section */
311 | 6961DAA41C13E23B00E7FA6D /* Main.storyboard */ = {
312 | isa = PBXVariantGroup;
313 | children = (
314 | 6961DAA51C13E23B00E7FA6D /* Base */,
315 | );
316 | name = Main.storyboard;
317 | sourceTree = "";
318 | };
319 | 6961DAA91C13E23B00E7FA6D /* LaunchScreen.storyboard */ = {
320 | isa = PBXVariantGroup;
321 | children = (
322 | 6961DAAA1C13E23B00E7FA6D /* Base */,
323 | );
324 | name = LaunchScreen.storyboard;
325 | sourceTree = "";
326 | };
327 | /* End PBXVariantGroup section */
328 |
329 | /* Begin XCBuildConfiguration section */
330 | 6961DAC31C13E23B00E7FA6D /* Debug */ = {
331 | isa = XCBuildConfiguration;
332 | buildSettings = {
333 | ALWAYS_SEARCH_USER_PATHS = NO;
334 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
335 | CLANG_CXX_LIBRARY = "libc++";
336 | CLANG_ENABLE_MODULES = YES;
337 | CLANG_ENABLE_OBJC_ARC = YES;
338 | CLANG_WARN_BOOL_CONVERSION = YES;
339 | CLANG_WARN_CONSTANT_CONVERSION = YES;
340 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
341 | CLANG_WARN_EMPTY_BODY = YES;
342 | CLANG_WARN_ENUM_CONVERSION = YES;
343 | CLANG_WARN_INT_CONVERSION = YES;
344 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
345 | CLANG_WARN_UNREACHABLE_CODE = YES;
346 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
347 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
348 | COPY_PHASE_STRIP = NO;
349 | DEBUG_INFORMATION_FORMAT = dwarf;
350 | ENABLE_STRICT_OBJC_MSGSEND = YES;
351 | ENABLE_TESTABILITY = YES;
352 | GCC_C_LANGUAGE_STANDARD = gnu99;
353 | GCC_DYNAMIC_NO_PIC = NO;
354 | GCC_NO_COMMON_BLOCKS = YES;
355 | GCC_OPTIMIZATION_LEVEL = 0;
356 | GCC_PREPROCESSOR_DEFINITIONS = (
357 | "DEBUG=1",
358 | "$(inherited)",
359 | );
360 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
361 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
362 | GCC_WARN_UNDECLARED_SELECTOR = YES;
363 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
364 | GCC_WARN_UNUSED_FUNCTION = YES;
365 | GCC_WARN_UNUSED_VARIABLE = YES;
366 | IPHONEOS_DEPLOYMENT_TARGET = 9.1;
367 | MTL_ENABLE_DEBUG_INFO = YES;
368 | ONLY_ACTIVE_ARCH = YES;
369 | SDKROOT = iphoneos;
370 | };
371 | name = Debug;
372 | };
373 | 6961DAC41C13E23B00E7FA6D /* Release */ = {
374 | isa = XCBuildConfiguration;
375 | buildSettings = {
376 | ALWAYS_SEARCH_USER_PATHS = NO;
377 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
378 | CLANG_CXX_LIBRARY = "libc++";
379 | CLANG_ENABLE_MODULES = YES;
380 | CLANG_ENABLE_OBJC_ARC = YES;
381 | CLANG_WARN_BOOL_CONVERSION = YES;
382 | CLANG_WARN_CONSTANT_CONVERSION = YES;
383 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
384 | CLANG_WARN_EMPTY_BODY = YES;
385 | CLANG_WARN_ENUM_CONVERSION = YES;
386 | CLANG_WARN_INT_CONVERSION = YES;
387 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
388 | CLANG_WARN_UNREACHABLE_CODE = YES;
389 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
390 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
391 | COPY_PHASE_STRIP = NO;
392 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
393 | ENABLE_NS_ASSERTIONS = NO;
394 | ENABLE_STRICT_OBJC_MSGSEND = YES;
395 | GCC_C_LANGUAGE_STANDARD = gnu99;
396 | GCC_NO_COMMON_BLOCKS = YES;
397 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
398 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
399 | GCC_WARN_UNDECLARED_SELECTOR = YES;
400 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
401 | GCC_WARN_UNUSED_FUNCTION = YES;
402 | GCC_WARN_UNUSED_VARIABLE = YES;
403 | IPHONEOS_DEPLOYMENT_TARGET = 9.1;
404 | MTL_ENABLE_DEBUG_INFO = NO;
405 | SDKROOT = iphoneos;
406 | VALIDATE_PRODUCT = YES;
407 | };
408 | name = Release;
409 | };
410 | 6961DAC61C13E23B00E7FA6D /* Debug */ = {
411 | isa = XCBuildConfiguration;
412 | buildSettings = {
413 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
414 | INFOPLIST_FILE = "iOS-Socket-C-Version-Server/Info.plist";
415 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
416 | PRODUCT_BUNDLE_IDENTIFIER = "com.huangyibiao.iOS-Socket-C-Version-Server";
417 | PRODUCT_NAME = "$(TARGET_NAME)";
418 | };
419 | name = Debug;
420 | };
421 | 6961DAC71C13E23B00E7FA6D /* Release */ = {
422 | isa = XCBuildConfiguration;
423 | buildSettings = {
424 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
425 | INFOPLIST_FILE = "iOS-Socket-C-Version-Server/Info.plist";
426 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
427 | PRODUCT_BUNDLE_IDENTIFIER = "com.huangyibiao.iOS-Socket-C-Version-Server";
428 | PRODUCT_NAME = "$(TARGET_NAME)";
429 | };
430 | name = Release;
431 | };
432 | 6961DAC91C13E23B00E7FA6D /* Debug */ = {
433 | isa = XCBuildConfiguration;
434 | buildSettings = {
435 | BUNDLE_LOADER = "$(TEST_HOST)";
436 | INFOPLIST_FILE = "iOS-Socket-C-Version-ServerTests/Info.plist";
437 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
438 | PRODUCT_BUNDLE_IDENTIFIER = "com.huangyibiao.iOS-Socket-C-Version-ServerTests";
439 | PRODUCT_NAME = "$(TARGET_NAME)";
440 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/iOS-Socket-C-Version-Server.app/iOS-Socket-C-Version-Server";
441 | };
442 | name = Debug;
443 | };
444 | 6961DACA1C13E23B00E7FA6D /* Release */ = {
445 | isa = XCBuildConfiguration;
446 | buildSettings = {
447 | BUNDLE_LOADER = "$(TEST_HOST)";
448 | INFOPLIST_FILE = "iOS-Socket-C-Version-ServerTests/Info.plist";
449 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
450 | PRODUCT_BUNDLE_IDENTIFIER = "com.huangyibiao.iOS-Socket-C-Version-ServerTests";
451 | PRODUCT_NAME = "$(TARGET_NAME)";
452 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/iOS-Socket-C-Version-Server.app/iOS-Socket-C-Version-Server";
453 | };
454 | name = Release;
455 | };
456 | 6961DACC1C13E23B00E7FA6D /* Debug */ = {
457 | isa = XCBuildConfiguration;
458 | buildSettings = {
459 | INFOPLIST_FILE = "iOS-Socket-C-Version-ServerUITests/Info.plist";
460 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
461 | PRODUCT_BUNDLE_IDENTIFIER = "com.huangyibiao.iOS-Socket-C-Version-ServerUITests";
462 | PRODUCT_NAME = "$(TARGET_NAME)";
463 | TEST_TARGET_NAME = "iOS-Socket-C-Version-Server";
464 | USES_XCTRUNNER = YES;
465 | };
466 | name = Debug;
467 | };
468 | 6961DACD1C13E23B00E7FA6D /* Release */ = {
469 | isa = XCBuildConfiguration;
470 | buildSettings = {
471 | INFOPLIST_FILE = "iOS-Socket-C-Version-ServerUITests/Info.plist";
472 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
473 | PRODUCT_BUNDLE_IDENTIFIER = "com.huangyibiao.iOS-Socket-C-Version-ServerUITests";
474 | PRODUCT_NAME = "$(TARGET_NAME)";
475 | TEST_TARGET_NAME = "iOS-Socket-C-Version-Server";
476 | USES_XCTRUNNER = YES;
477 | };
478 | name = Release;
479 | };
480 | /* End XCBuildConfiguration section */
481 |
482 | /* Begin XCConfigurationList section */
483 | 6961DA931C13E23B00E7FA6D /* Build configuration list for PBXProject "iOS-Socket-C-Version-Server" */ = {
484 | isa = XCConfigurationList;
485 | buildConfigurations = (
486 | 6961DAC31C13E23B00E7FA6D /* Debug */,
487 | 6961DAC41C13E23B00E7FA6D /* Release */,
488 | );
489 | defaultConfigurationIsVisible = 0;
490 | defaultConfigurationName = Release;
491 | };
492 | 6961DAC51C13E23B00E7FA6D /* Build configuration list for PBXNativeTarget "iOS-Socket-C-Version-Server" */ = {
493 | isa = XCConfigurationList;
494 | buildConfigurations = (
495 | 6961DAC61C13E23B00E7FA6D /* Debug */,
496 | 6961DAC71C13E23B00E7FA6D /* Release */,
497 | );
498 | defaultConfigurationIsVisible = 0;
499 | };
500 | 6961DAC81C13E23B00E7FA6D /* Build configuration list for PBXNativeTarget "iOS-Socket-C-Version-ServerTests" */ = {
501 | isa = XCConfigurationList;
502 | buildConfigurations = (
503 | 6961DAC91C13E23B00E7FA6D /* Debug */,
504 | 6961DACA1C13E23B00E7FA6D /* Release */,
505 | );
506 | defaultConfigurationIsVisible = 0;
507 | };
508 | 6961DACB1C13E23B00E7FA6D /* Build configuration list for PBXNativeTarget "iOS-Socket-C-Version-ServerUITests" */ = {
509 | isa = XCConfigurationList;
510 | buildConfigurations = (
511 | 6961DACC1C13E23B00E7FA6D /* Debug */,
512 | 6961DACD1C13E23B00E7FA6D /* Release */,
513 | );
514 | defaultConfigurationIsVisible = 0;
515 | };
516 | /* End XCConfigurationList section */
517 | };
518 | rootObject = 6961DA901C13E23B00E7FA6D /* Project object */;
519 | }
520 |
--------------------------------------------------------------------------------
/iOS-Socket-C-Version-Server/iOS-Socket-C-Version-Server.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/iOS-Socket-C-Version-Server/iOS-Socket-C-Version-Server.xcodeproj/project.xcworkspace/xcuserdata/huangyibiao.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoderJackyHuang/iOS-Socket-C-Version/d265cbcccf4fab4a5e4d2538f574fcacae87f64d/iOS-Socket-C-Version-Server/iOS-Socket-C-Version-Server.xcodeproj/project.xcworkspace/xcuserdata/huangyibiao.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/iOS-Socket-C-Version-Server/iOS-Socket-C-Version-Server.xcodeproj/xcuserdata/huangyibiao.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/iOS-Socket-C-Version-Server/iOS-Socket-C-Version-Server.xcodeproj/xcuserdata/huangyibiao.xcuserdatad/xcschemes/iOS-Socket-C-Version-Server.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
43 |
49 |
50 |
51 |
52 |
53 |
59 |
60 |
61 |
62 |
63 |
64 |
74 |
76 |
82 |
83 |
84 |
85 |
86 |
87 |
93 |
95 |
101 |
102 |
103 |
104 |
106 |
107 |
110 |
111 |
112 |
--------------------------------------------------------------------------------
/iOS-Socket-C-Version-Server/iOS-Socket-C-Version-Server.xcodeproj/xcuserdata/huangyibiao.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | iOS-Socket-C-Version-Server.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 6961DA971C13E23B00E7FA6D
16 |
17 | primary
18 |
19 |
20 | 6961DAB01C13E23B00E7FA6D
21 |
22 | primary
23 |
24 |
25 | 6961DABB1C13E23B00E7FA6D
26 |
27 | primary
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/iOS-Socket-C-Version-Server/iOS-Socket-C-Version-Server/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // iOS-Socket-C-Version-Server
4 | //
5 | // Created by huangyibiao on 15/12/6.
6 | // Copyright © 2015年 huangyibiao. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/iOS-Socket-C-Version-Server/iOS-Socket-C-Version-Server/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // iOS-Socket-C-Version-Server
4 | //
5 | // Created by huangyibiao on 15/12/6.
6 | // Copyright © 2015年 huangyibiao. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 |
18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
19 | // Override point for customization after application launch.
20 | return YES;
21 | }
22 |
23 | - (void)applicationWillResignActive:(UIApplication *)application {
24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
26 | }
27 |
28 | - (void)applicationDidEnterBackground:(UIApplication *)application {
29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
31 | }
32 |
33 | - (void)applicationWillEnterForeground:(UIApplication *)application {
34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
35 | }
36 |
37 | - (void)applicationDidBecomeActive:(UIApplication *)application {
38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
39 | }
40 |
41 | - (void)applicationWillTerminate:(UIApplication *)application {
42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
43 | }
44 |
45 | @end
46 |
--------------------------------------------------------------------------------
/iOS-Socket-C-Version-Server/iOS-Socket-C-Version-Server/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | }
33 | ],
34 | "info" : {
35 | "version" : 1,
36 | "author" : "xcode"
37 | }
38 | }
--------------------------------------------------------------------------------
/iOS-Socket-C-Version-Server/iOS-Socket-C-Version-Server/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/iOS-Socket-C-Version-Server/iOS-Socket-C-Version-Server/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/iOS-Socket-C-Version-Server/iOS-Socket-C-Version-Server/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/iOS-Socket-C-Version-Server/iOS-Socket-C-Version-Server/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // iOS-Socket-C-Version-Server
4 | //
5 | // Created by huangyibiao on 15/12/6.
6 | // Copyright © 2015年 huangyibiao. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/iOS-Socket-C-Version-Server/iOS-Socket-C-Version-Server/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // iOS-Socket-C-Version-Server
4 | //
5 | // Created by huangyibiao on 15/12/6.
6 | // Copyright © 2015年 huangyibiao. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #include
11 | #include
12 | #include
13 |
14 | @interface ViewController ()
15 |
16 | @end
17 |
18 | @implementation ViewController
19 |
20 | - (void)viewDidLoad {
21 | [super viewDidLoad];
22 |
23 | // [self tcpServer];
24 | [self udpServer];
25 | }
26 |
27 | - (void)tcpServer {
28 | // 第一步:创建socket
29 | int error = -1;
30 |
31 | // 创建socket套接字
32 | int serverSocketId = socket(AF_INET, SOCK_STREAM, 0);
33 | // 判断创建socket是否成功
34 | BOOL success = (serverSocketId != -1);
35 |
36 | // 第二步:绑定端口号
37 | if (success) {
38 | NSLog(@"server socket create success");
39 | // Socket address
40 | struct sockaddr_in addr;
41 |
42 | // 初始化全置为0
43 | memset(&addr, 0, sizeof(addr));
44 |
45 | // 指定socket地址长度
46 | addr.sin_len = sizeof(addr);
47 |
48 | // 指定网络协议,比如这里使用的是TCP/UDP则指定为AF_INET
49 | addr.sin_family = AF_INET;
50 |
51 | // 指定端口号
52 | addr.sin_port = htons(1024);
53 |
54 | // 指定监听的ip,指定为INADDR_ANY时,表示监听所有的ip
55 | addr.sin_addr.s_addr = INADDR_ANY;
56 |
57 | // 绑定套接字
58 | error = bind(serverSocketId, (const struct sockaddr *)&addr, sizeof(addr));
59 | success = (error == 0);
60 | }
61 |
62 | // 第三步:监听
63 | if (success) {
64 | NSLog(@"bind server socket success");
65 | error = listen(serverSocketId, 5);
66 | success = (error == 0);
67 | }
68 |
69 | if (success) {
70 | NSLog(@"listen server socket success");
71 |
72 | while (true) {
73 | // p2p
74 | struct sockaddr_in peerAddr;
75 | int peerSocketId;
76 | socklen_t addrLen = sizeof(peerAddr);
77 |
78 | // 第四步:等待客户端连接
79 | // 服务器端等待从编号为serverSocketId的Socket上接收客户连接请求
80 | peerSocketId = accept(serverSocketId, (struct sockaddr *)&peerAddr, &addrLen);
81 | success = (peerSocketId != -1);
82 |
83 | if (success) {
84 | NSLog(@"accept server socket success,remote address:%s,port:%d",
85 | inet_ntoa(peerAddr.sin_addr),
86 | ntohs(peerAddr.sin_port));
87 | char buf[1024];
88 | size_t len = sizeof(buf);
89 |
90 | // 第五步:接收来自客户端的信息
91 | // 当客户端输入exit时才退出
92 | do {
93 | // 接收来自客户端的信息
94 | recv(peerSocketId, buf, len, 0);
95 | if (strlen(buf) != 0) {
96 | NSString *str = [NSString stringWithCString:buf encoding:NSUTF8StringEncoding];
97 | if (str.length >= 1) {
98 | NSLog(@"received message from client:%@",str);
99 | }
100 | }
101 | } while (strcmp(buf, "exit") != 0);
102 |
103 | NSLog(@"收到exit信号,本次socket通信完毕");
104 |
105 | // 第六步:关闭socket
106 | close(peerSocketId);
107 | }
108 | }
109 | }
110 | }
111 |
112 | - (void)udpServer {
113 | int serverSockerId = -1;
114 | ssize_t len = -1;
115 | socklen_t addrlen;
116 | char buff[1024];
117 | struct sockaddr_in ser_addr;
118 |
119 | // 第一步:创建socket
120 | // 注意,第二个参数是SOCK_DGRAM,因为udp是数据报格式的
121 | serverSockerId = socket(AF_INET, SOCK_DGRAM, 0);
122 |
123 | if(serverSockerId < 0) {
124 | NSLog(@"Create server socket fail");
125 | return;
126 | }
127 |
128 | addrlen = sizeof(struct sockaddr_in);
129 | bzero(&ser_addr, addrlen);
130 |
131 | ser_addr.sin_family = AF_INET;
132 | ser_addr.sin_addr.s_addr = htonl(INADDR_ANY);
133 | ser_addr.sin_port = htons(1024);
134 |
135 | // 第二步:绑定端口号
136 | if(bind(serverSockerId, (struct sockaddr *)&ser_addr, addrlen) < 0) {
137 | NSLog(@"server connect socket fail");
138 | return;
139 | }
140 |
141 | do {
142 | bzero(buff, sizeof(buff));
143 |
144 | // 第三步:接收客户端的消息
145 | len = recvfrom(serverSockerId, buff, sizeof(buff), 0, (struct sockaddr *)&ser_addr, &addrlen);
146 | // 显示client端的网络地址
147 | NSLog(@"receive from %s\n", inet_ntoa(ser_addr.sin_addr));
148 | // 显示客户端发来的字符串
149 | NSLog(@"recevce:%s", buff);
150 |
151 | // 第四步:将接收到的客户端发来的消息,发回客户端
152 | // 将字串返回给client端
153 | sendto(serverSockerId, buff, len, 0, (struct sockaddr *)&ser_addr, addrlen);
154 | } while (strcmp(buff, "exit") != 0);
155 |
156 | // 第五步:关闭socket
157 | close(serverSockerId);
158 | }
159 |
160 | @end
161 |
--------------------------------------------------------------------------------
/iOS-Socket-C-Version-Server/iOS-Socket-C-Version-Server/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // iOS-Socket-C-Version-Server
4 | //
5 | // Created by huangyibiao on 15/12/6.
6 | // Copyright © 2015年 huangyibiao. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/iOS-Socket-C-Version-Server/iOS-Socket-C-Version-ServerTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/iOS-Socket-C-Version-Server/iOS-Socket-C-Version-ServerTests/iOS_Socket_C_Version_ServerTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // iOS_Socket_C_Version_ServerTests.m
3 | // iOS-Socket-C-Version-ServerTests
4 | //
5 | // Created by huangyibiao on 15/12/6.
6 | // Copyright © 2015年 huangyibiao. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface iOS_Socket_C_Version_ServerTests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation iOS_Socket_C_Version_ServerTests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 | // Put setup code here. This method is called before the invocation of each test method in the class.
20 | }
21 |
22 | - (void)tearDown {
23 | // Put teardown code here. This method is called after the invocation of each test method in the class.
24 | [super tearDown];
25 | }
26 |
27 | - (void)testExample {
28 | // This is an example of a functional test case.
29 | // Use XCTAssert and related functions to verify your tests produce the correct results.
30 | }
31 |
32 | - (void)testPerformanceExample {
33 | // This is an example of a performance test case.
34 | [self measureBlock:^{
35 | // Put the code you want to measure the time of here.
36 | }];
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/iOS-Socket-C-Version-Server/iOS-Socket-C-Version-ServerUITests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/iOS-Socket-C-Version-Server/iOS-Socket-C-Version-ServerUITests/iOS_Socket_C_Version_ServerUITests.m:
--------------------------------------------------------------------------------
1 | //
2 | // iOS_Socket_C_Version_ServerUITests.m
3 | // iOS-Socket-C-Version-ServerUITests
4 | //
5 | // Created by huangyibiao on 15/12/6.
6 | // Copyright © 2015年 huangyibiao. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface iOS_Socket_C_Version_ServerUITests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation iOS_Socket_C_Version_ServerUITests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 |
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 |
22 | // In UI tests it is usually best to stop immediately when a failure occurs.
23 | self.continueAfterFailure = NO;
24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
25 | [[[XCUIApplication alloc] init] launch];
26 |
27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
28 | }
29 |
30 | - (void)tearDown {
31 | // Put teardown code here. This method is called after the invocation of each test method in the class.
32 | [super tearDown];
33 | }
34 |
35 | - (void)testExample {
36 | // Use recording to get started writing UI tests.
37 | // Use XCTAssert and related functions to verify your tests produce the correct results.
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------