Compare commits

..

1 Commits

Author SHA1 Message Date
Dan Shevlyuk
026e2f05fe Move servers and clients to separate fies 2017-01-06 17:55:04 +03:00
14 changed files with 218 additions and 247 deletions

View File

@ -78,10 +78,10 @@ switch client.connect(timeout: 1) {
## Server socket example (echo server)
``` swift
func echoService(client: TCPClient) {
print("Newclient from:\(client.address)[\(client.port)]")
var d = client.read(1024*10)
client.send(data: d!)
client.close()
print("Newclient from:\(c.address)[\(c.port)]")
var d = c.read(1024*10)
c.send(data: d!)
c.close()
}
func testServer() {

View File

@ -32,14 +32,11 @@ import Foundation
@_silgen_name("ytcpsocket_connect") private func c_ytcpsocket_connect(_ host:UnsafePointer<Byte>,port:Int32,timeout:Int32) -> Int32
@_silgen_name("ytcpsocket_close") private func c_ytcpsocket_close(_ fd:Int32) -> Int32
@_silgen_name("ytcpsocket_bytes_available") private func c_ytcpsocket_bytes_available(_ fd:Int32) -> Int32
@_silgen_name("ytcpsocket_send") private func c_ytcpsocket_send(_ fd:Int32,buff:UnsafePointer<Byte>,len:Int32) -> Int32
@_silgen_name("ytcpsocket_pull") private func c_ytcpsocket_pull(_ fd:Int32,buff:UnsafePointer<Byte>,len:Int32,timeout:Int32) -> Int32
@_silgen_name("ytcpsocket_listen") private func c_ytcpsocket_listen(_ address:UnsafePointer<Int8>,port:Int32)->Int32
@_silgen_name("ytcpsocket_accept") private func c_ytcpsocket_accept(_ onsocketfd:Int32,ip:UnsafePointer<Int8>,port:UnsafePointer<Int32>,timeout:Int32) -> Int32
@_silgen_name("ytcpsocket_port") private func c_ytcpsocket_port(_ fd:Int32) -> Int32
open class TCPClient: Socket {
/*
* connect to server
* return success or fail with message
@ -62,7 +59,7 @@ open class TCPClient: Socket {
}
}
}
/*
* close socket
* return success or fail with message
@ -136,66 +133,4 @@ open class TCPClient: Socket {
return data
}
/*
* gets byte available for reading
*/
open func bytesAvailable() -> Int32? {
guard let fd:Int32 = self.fd else { return nil }
let bytesAvailable = c_ytcpsocket_bytes_available(fd);
if (bytesAvailable < 0) {
return nil
}
return bytesAvailable
}
}
open class TCPServer: Socket {
open func listen() -> Result {
let fd = c_ytcpsocket_listen(self.address, port: Int32(self.port))
if fd > 0 {
self.fd = fd
// If port 0 is used, get the actual port number which the server is listening to
if (self.port == 0) {
let p = c_ytcpsocket_port(fd)
if (p == -1) {
return .failure(SocketError.unknownError)
} else {
self.port = p
}
}
return .success
} else {
return .failure(SocketError.unknownError)
}
}
open func accept(timeout :Int32 = 0) -> TCPClient? {
guard let serferfd = self.fd else { return nil }
var buff: [Int8] = [Int8](repeating: 0x0,count: 16)
var port: Int32 = 0
let clientfd: Int32 = c_ytcpsocket_accept(serferfd, ip: &buff, port: &port, timeout: timeout)
guard clientfd >= 0 else { return nil }
guard let address = String(cString: buff, encoding: String.Encoding.utf8) else { return nil }
let client = TCPClient(address: address, port: port)
client.fd = clientfd
return client
}
open func close() {
guard let fd: Int32=self.fd else { return }
_ = c_ytcpsocket_close(fd)
self.fd = nil
}
}

83
Sources/TCPServer.swift Normal file
View File

@ -0,0 +1,83 @@
//
// Copyright (c) <2014>, skysent
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. All advertising materials mentioning features or use of this software
// must display the following acknowledgement:
// This product includes software developed by skysent.
// 4. Neither the name of the skysent nor the
// names of its contributors may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY skysent ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL skysent BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
import Foundation
@_silgen_name("ytcpsocket_listen") private func c_ytcpsocket_listen(_ address:UnsafePointer<Int8>,port:Int32)->Int32
@_silgen_name("ytcpsocket_accept") private func c_ytcpsocket_accept(_ onsocketfd:Int32,ip:UnsafePointer<Int8>,port:UnsafePointer<Int32>) -> Int32
@_silgen_name("ytcpsocket_port") private func c_ytcpsocket_port(_ fd:Int32) -> Int32
@_silgen_name("ytcpsocket_close") private func c_ytcpsocket_close(_ fd:Int32) -> Int32
open class TCPServer: Socket {
open func listen() -> Result {
let fd = c_ytcpsocket_listen(self.address, port: Int32(self.port))
if fd > 0 {
self.fd = fd
// If port 0 is used, get the actual port number which the server is listening to
if (self.port == 0) {
let p = c_ytcpsocket_port(fd)
if (p == -1) {
return .failure(SocketError.unknownError)
} else {
self.port = p
}
}
return .success
} else {
return .failure(SocketError.unknownError)
}
}
open func accept() -> TCPClient? {
guard let serferfd = self.fd else { return nil }
var buff: [Int8] = [Int8](repeating: 0x0,count: 16)
var port: Int32 = 0
let clientfd: Int32 = c_ytcpsocket_accept(serferfd, ip: &buff, port: &port)
guard clientfd >= 0 else { return nil }
guard let address = String(cString: buff, encoding: String.Encoding.utf8) else { return nil }
let client = TCPClient(address: address, port: port)
client.fd = clientfd
return client
}
open func close() {
guard let fd: Int32=self.fd else { return }
_ = c_ytcpsocket_close(fd)
self.fd = nil
}
}

View File

@ -30,8 +30,6 @@
import Foundation
@_silgen_name("yudpsocket_server") func c_yudpsocket_server(_ host:UnsafePointer<Int8>,port:Int32) -> Int32
@_silgen_name("yudpsocket_recive") func c_yudpsocket_recive(_ fd:Int32,buff:UnsafePointer<Byte>,len:Int32,ip:UnsafePointer<Int8>,port:UnsafePointer<Int32>) -> Int32
@_silgen_name("yudpsocket_close") func c_yudpsocket_close(_ fd:Int32) -> Int32
@_silgen_name("yudpsocket_client") func c_yudpsocket_client() -> Int32
@_silgen_name("yudpsocket_get_server_ip") func c_yudpsocket_get_server_ip(_ host:UnsafePointer<Int8>,ip:UnsafePointer<Int8>) -> Int32
@ -111,26 +109,6 @@ open class UDPClient: Socket {
}
}
//TODO add multycast and boardcast
open func recv(_ expectlen: Int) -> ([Byte]?, String, Int) {
guard let fd = self.fd else {
return (nil, "no ip", 0)
}
let buff: [Byte] = [Byte](repeating: 0x0, count: expectlen)
var remoteipbuff: [Int8] = [Int8](repeating: 0x0, count: 16)
var remoteport: Int32 = 0
let readLen: Int32 = c_yudpsocket_recive(fd, buff: buff, len: Int32(expectlen), ip: &remoteipbuff, port: &remoteport)
let port: Int = Int(remoteport)
let address = String(cString: remoteipbuff, encoding: String.Encoding.utf8) ?? ""
if readLen <= 0 {
return (nil, address, port)
}
let data: [Byte] = Array(buff[0..<Int(readLen)])
return (data, address, port)
}
open func close() {
guard let fd = self.fd else { return }
@ -139,47 +117,3 @@ open class UDPClient: Socket {
}
//TODO add multycast and boardcast
}
open class UDPServer: Socket {
public override init(address: String, port: Int32) {
super.init(address: address, port: port)
let fd = c_yudpsocket_server(address, port: port)
if fd > 0 {
self.fd = fd
}
}
//TODO add multycast and boardcast
open func recv(_ expectlen: Int) -> ([Byte]?, String, Int) {
if let fd = self.fd {
let buff: [Byte] = [Byte](repeating: 0x0,count: expectlen)
var remoteipbuff: [Int8] = [Int8](repeating: 0x0,count: 16)
var remoteport: Int32 = 0
let readLen: Int32 = c_yudpsocket_recive(fd, buff: buff, len: Int32(expectlen), ip: &remoteipbuff, port: &remoteport)
let port: Int = Int(remoteport)
var address = ""
if let ip = String(cString: remoteipbuff, encoding: String.Encoding.utf8) {
address = ip
}
if readLen <= 0 {
return (nil, address, port)
}
let rs = buff[0...Int(readLen-1)]
let data: [Byte] = Array(rs)
return (data, address, port)
}
return (nil, "no ip", 0)
}
open func close() {
guard let fd = self.fd else { return }
_ = c_yudpsocket_close(fd)
self.fd = nil
}
}

78
Sources/UDPServer.swift Normal file
View File

@ -0,0 +1,78 @@
//
// Copyright (c) <2014>, skysent
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. All advertising materials mentioning features or use of this software
// must display the following acknowledgement:
// This product includes software developed by skysent.
// 4. Neither the name of the skysent nor the
// names of its contributors may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY skysent ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL skysent BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
import Foundation
@_silgen_name("yudpsocket_server") func c_yudpsocket_server(_ host:UnsafePointer<Int8>,port:Int32) -> Int32
@_silgen_name("yudpsocket_recive") func c_yudpsocket_recive(_ fd:Int32,buff:UnsafePointer<Byte>,len:Int32,ip:UnsafePointer<Int8>,port:UnsafePointer<Int32>) -> Int32
open class UDPServer: Socket {
public override init(address: String, port: Int32) {
super.init(address: address, port: port)
let fd = c_yudpsocket_server(address, port: port)
if fd > 0 {
self.fd = fd
}
}
//TODO add multycast and boardcast
open func recv(_ expectlen: Int) -> ([Byte]?, String, Int) {
if let fd = self.fd {
var buff: [Byte] = [Byte](repeating: 0x0,count: expectlen)
var remoteipbuff: [Int8] = [Int8](repeating: 0x0,count: 16)
var remoteport: Int32 = 0
let readLen: Int32 = c_yudpsocket_recive(fd, buff: buff, len: Int32(expectlen), ip: &remoteipbuff, port: &remoteport)
let port: Int = Int(remoteport)
var address = ""
if let ip = String(cString: remoteipbuff, encoding: String.Encoding.utf8) {
address = ip
}
if readLen <= 0 {
return (nil, address, port)
}
let rs = buff[0...Int(readLen-1)]
let data: [Byte] = Array(rs)
return (data, address, port)
}
return (nil, "no ip", 0)
}
open func close() {
guard let fd = self.fd else { return }
_ = c_yudpsocket_close(fd)
self.fd = nil
}
}

View File

@ -37,14 +37,12 @@
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <dirent.h>
#include <netdb.h>
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/select.h>
#include <sys/ioctl.h>
void ytcpsocket_set_block(int socket, int on) {
int flags;
@ -95,6 +93,7 @@ int ytcpsocket_connect(const char *host, int port, int timeout) {
return -4;//connect fail
}
ytcpsocket_set_block(sockfd, 1);
int set = 1;
setsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, (void *)&set, sizeof(int));
return sockfd;
@ -106,8 +105,6 @@ int ytcpsocket_close(int socketfd){
}
int ytcpsocket_pull(int socketfd, char *data, int len, int timeout_sec) {
int readlen = 0;
int datalen = 0;
if (timeout_sec > 0) {
fd_set fdset;
struct timeval timeout;
@ -120,26 +117,8 @@ int ytcpsocket_pull(int socketfd, char *data, int len, int timeout_sec) {
return ret; // select-call failed or timeout occurred (before anything was sent)
}
}
// use loop to make sure receive all data
do {
readlen = (int)read(socketfd, data + datalen, len - datalen);
if (readlen > 0) {
datalen += readlen;
}
} while (readlen > 0);
return datalen;
}
int ytcpsocket_bytes_available(int socketfd) {
int count;
int callResult = ioctl(socketfd, FIONREAD, &count);
if (callResult < 0) {
return callResult;
}
return count;
int readlen = (int)read(socketfd, data, len);
return readlen;
}
int ytcpsocket_send(int socketfd, const char *data, int len){
@ -180,31 +159,15 @@ int ytcpsocket_listen(const char *address, int port) {
}
//return client socket fd
int ytcpsocket_accept(int onsocketfd, char *remoteip, int *remoteport, int timeouts) {
int ytcpsocket_accept(int onsocketfd, char *remoteip, int *remoteport) {
socklen_t clilen;
struct sockaddr_in cli_addr;
clilen = sizeof(cli_addr);
fd_set fdset;
FD_ZERO(&fdset);
FD_SET(onsocketfd, &fdset);
struct timeval *timeptr = NULL;
struct timeval timeout;
if (timeouts > 0) {
timeout.tv_sec = timeouts;
timeout.tv_usec = 0;
timeptr = &timeout;
}
int status = select(FD_SETSIZE, &fdset, NULL, NULL, timeptr);
if (status != 1) {
return -1;
}
int newsockfd = accept(onsocketfd, (struct sockaddr *) &cli_addr, &clilen);
char *clientip=inet_ntoa(cli_addr.sin_addr);
memcpy(remoteip, clientip, strlen(clientip));
*remoteport = cli_addr.sin_port;
if (newsockfd > 0) {
int set = 1;
setsockopt(newsockfd, SOL_SOCKET, SO_NOSIGPIPE, (void*) &set, sizeof(int));
return newsockfd;
} else {
return -1;

View File

@ -48,7 +48,6 @@ int yudpsocket_server(const char *address, int port) {
//bind
struct sockaddr_in serv_addr;
memset( &serv_addr, '\0', sizeof(serv_addr));
serv_addr.sin_len = sizeof(struct sockaddr_in);
serv_addr.sin_family = AF_INET;
if (address == NULL || strlen(address) == 0 || strcmp(address, "255.255.255.255") == 0) {
@ -59,6 +58,7 @@ int yudpsocket_server(const char *address, int port) {
r = setsockopt(socketfd, SOL_SOCKET, SO_REUSEADDR, &reuseon, sizeof(reuseon));
serv_addr.sin_addr.s_addr = inet_addr(address);
serv_addr.sin_port = htons(port);
memset( &serv_addr, '\0', sizeof(serv_addr));
}
if (r == -1) {
@ -95,10 +95,6 @@ int yudpsocket_client() {
int socketfd = socket(AF_INET, SOCK_DGRAM, 0);
int reuseon = 1;
setsockopt(socketfd, SOL_SOCKET, SO_REUSEADDR, &reuseon, sizeof(reuseon));
//disable SIGPIPE as we'll handle send errors ourselves
int noSigPipe = 1;
setsockopt(socketfd, SOL_SOCKET, SO_NOSIGPIPE, &noSigPipe, sizeof(noSigPipe));
return socketfd;
}

View File

@ -1,11 +1,11 @@
Pod::Spec.new do |s|
s.name = 'SwiftSocket'
s.version = '2.0.2'
s.version = '2.0.1'
s.summary = 'A cool framework to work with TCP and UDP sockets'
s.description = <<-DESC
SwiftSocket provides an easy way to create TCP or UDP clients and servers 💁
SwiftSocket profieds an easy way to create TCP or UDP clients and servers 💁
DESC
s.homepage = 'https://github.com/swiftsocket/SwiftSocket'
@ -23,6 +23,6 @@ Pod::Spec.new do |s|
:tag => s.version
}
s.source_files = 'Sources/**/*.{swift,c}'
s.pod_target_xcconfig = { 'SWIFT_VERSION' => '5' }
s.pod_target_xcconfig = { 'SWIFT_VERSION' => '3' }
end

View File

@ -33,6 +33,12 @@
375C48351DDC4C56008C701D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 375C48331DDC4C56008C701D /* Main.storyboard */; };
375C48371DDC4C56008C701D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 375C48361DDC4C56008C701D /* Assets.xcassets */; };
375C483A1DDC4C56008C701D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 375C48381DDC4C56008C701D /* LaunchScreen.storyboard */; };
37DA08A81E1FDD6D00C88E31 /* TCPServer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37DA08A71E1FDD6D00C88E31 /* TCPServer.swift */; };
37DA08A91E1FDD6D00C88E31 /* TCPServer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37DA08A71E1FDD6D00C88E31 /* TCPServer.swift */; };
37DA08AA1E1FDD6D00C88E31 /* TCPServer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37DA08A71E1FDD6D00C88E31 /* TCPServer.swift */; };
37DA08B01E1FDE3500C88E31 /* UDPServer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37DA08AF1E1FDE3500C88E31 /* UDPServer.swift */; };
37DA08B11E1FDE3500C88E31 /* UDPServer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37DA08AF1E1FDE3500C88E31 /* UDPServer.swift */; };
37DA08B21E1FDE3500C88E31 /* UDPServer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37DA08AF1E1FDE3500C88E31 /* UDPServer.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@ -55,6 +61,8 @@
375C483B1DDC4C56008C701D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
377DAA691DCDE40200009697 /* SwiftSocket.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftSocket.framework; sourceTree = BUILT_PRODUCTS_DIR; };
377DAA761DCDE45D00009697 /* SwiftSocket.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftSocket.framework; sourceTree = BUILT_PRODUCTS_DIR; };
37DA08A71E1FDD6D00C88E31 /* TCPServer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = TCPServer.swift; path = Sources/TCPServer.swift; sourceTree = SOURCE_ROOT; };
37DA08AF1E1FDE3500C88E31 /* UDPServer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = UDPServer.swift; path = Sources/UDPServer.swift; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -89,22 +97,24 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
375BC51D1DCDE86B006AD8F6 /* TCPSocket */ = {
375BC51D1DCDE86B006AD8F6 /* TCP */ = {
isa = PBXGroup;
children = (
372313941DCF84E30042DA87 /* TCPClient.swift */,
37DA08A71E1FDD6D00C88E31 /* TCPServer.swift */,
372313951DCF84E30042DA87 /* ytcpsocket.c */,
);
name = TCPSocket;
name = TCP;
sourceTree = "<group>";
};
375BC51E1DCDE878006AD8F6 /* UDPSocket */ = {
375BC51E1DCDE878006AD8F6 /* UDP */ = {
isa = PBXGroup;
children = (
372313901DCF84D80042DA87 /* UDPClient.swift */,
37DA08AF1E1FDE3500C88E31 /* UDPServer.swift */,
372313911DCF84D80042DA87 /* yudpsocket.c */,
);
name = UDPSocket;
name = UDP;
sourceTree = "<group>";
};
375C482E1DDC4C56008C701D /* iOS Example */ = {
@ -156,8 +166,8 @@
children = (
372313981DCF84EC0042DA87 /* Result.swift */,
372313991DCF84EC0042DA87 /* Socket.swift */,
375BC51D1DCDE86B006AD8F6 /* TCPSocket */,
375BC51E1DCDE878006AD8F6 /* UDPSocket */,
375BC51D1DCDE86B006AD8F6 /* TCP */,
375BC51E1DCDE878006AD8F6 /* UDP */,
377DAA6A1DCDE40200009697 /* Supporting Files */,
);
name = Source;
@ -273,12 +283,11 @@
attributes = {
LastSwiftMigration = 0710;
LastSwiftUpdateCheck = 0810;
LastUpgradeCheck = 1020;
LastUpgradeCheck = 0710;
ORGANIZATIONNAME = swift;
TargetAttributes = {
37454EC91E06158200800AE5 = {
CreatedOnToolsVersion = 8.2;
LastSwiftMigration = 1020;
ProvisioningStyle = Manual;
};
375C482C1DDC4C56008C701D = {
@ -287,19 +296,18 @@
};
377DAA681DCDE40200009697 = {
CreatedOnToolsVersion = 8.1;
LastSwiftMigration = 1020;
LastSwiftMigration = 0810;
ProvisioningStyle = Manual;
};
377DAA751DCDE45D00009697 = {
CreatedOnToolsVersion = 8.1;
LastSwiftMigration = 1020;
ProvisioningStyle = Manual;
};
};
};
buildConfigurationList = 5518C82A19A3290F0049DC22 /* Build configuration list for PBXProject "SwiftSocket" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = en;
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
@ -359,9 +367,11 @@
files = (
37454EE31E06163D00800AE5 /* UDPClient.swift in Sources */,
37454EE01E06163D00800AE5 /* Socket.swift in Sources */,
37DA08B21E1FDE3500C88E31 /* UDPServer.swift in Sources */,
37454EE41E06163D00800AE5 /* yudpsocket.c in Sources */,
37454EDF1E06163D00800AE5 /* Result.swift in Sources */,
37454EE21E06163D00800AE5 /* ytcpsocket.c in Sources */,
37DA08AA1E1FDD6D00C88E31 /* TCPServer.swift in Sources */,
37454EE11E06163D00800AE5 /* TCPClient.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
@ -381,9 +391,11 @@
files = (
372313931DCF84D80042DA87 /* yudpsocket.c in Sources */,
3723139A1DCF84EC0042DA87 /* Result.swift in Sources */,
37DA08B01E1FDE3500C88E31 /* UDPServer.swift in Sources */,
3723139B1DCF84EC0042DA87 /* Socket.swift in Sources */,
372313921DCF84D80042DA87 /* UDPClient.swift in Sources */,
372313971DCF84E30042DA87 /* ytcpsocket.c in Sources */,
37DA08A81E1FDD6D00C88E31 /* TCPServer.swift in Sources */,
372313961DCF84E30042DA87 /* TCPClient.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
@ -394,9 +406,11 @@
files = (
37454EDC1E06163C00800AE5 /* UDPClient.swift in Sources */,
37454ED91E06163C00800AE5 /* Socket.swift in Sources */,
37DA08B11E1FDE3500C88E31 /* UDPServer.swift in Sources */,
37454EDD1E06163C00800AE5 /* yudpsocket.c in Sources */,
37454ED81E06163C00800AE5 /* Result.swift in Sources */,
37454EDB1E06163C00800AE5 /* ytcpsocket.c in Sources */,
37DA08A91E1FDD6D00C88E31 /* TCPServer.swift in Sources */,
37454EDA1E06163C00800AE5 /* TCPClient.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
@ -447,8 +461,8 @@
SDKROOT = appletvos;
SKIP_INSTALL = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 3;
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
@ -479,8 +493,8 @@
SDKROOT = appletvos;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 3;
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
@ -504,7 +518,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
@ -527,7 +541,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
@ -561,7 +575,7 @@
SKIP_INSTALL = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
@ -595,7 +609,7 @@
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
@ -623,7 +637,7 @@
PRODUCT_NAME = SwiftSocket;
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
TVOS_DEPLOYMENT_TARGET = 9.0;
};
@ -649,7 +663,7 @@
PRODUCT_NAME = SwiftSocket;
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
TVOS_DEPLOYMENT_TARGET = 9.0;
VALIDATE_PRODUCT = YES;
@ -660,28 +674,17 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
@ -689,7 +692,6 @@
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
@ -709,7 +711,7 @@
PRODUCT_NAME = "";
SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 3.0;
};
name = Debug;
};
@ -717,35 +719,23 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
@ -757,8 +747,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_NAME = "";
SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 3.0;
};
name = Release;
};

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
LastUpgradeVersion = "0820"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
LastUpgradeVersion = "0820"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
LastUpgradeVersion = "0820"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View File

@ -12,8 +12,9 @@ import UIKit
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
return true
}