biatoms / socket.swift Goto Github PK
View Code? Open in Web Editor NEWA POSIX socket wrapper written in swift.
License: MIT License
A POSIX socket wrapper written in swift.
License: MIT License
Hello,
I implemented the code in my demo project but it seems that I am making some mistake and hence I am getting the connection error saying that connection refused. I tried with the port and the IP address. Could you please suggest me how can I solve this? Below I am sending you the code which I have implemented.
Client Side:
do {
let client = try Socket(.inet, type: .stream, protocol: .tcp) // create client socket
do {
try client.connect(port: 8080, address: "192.168.1.50")
}
catch {
print(error)
}
var buffer = [UInt8](repeating: 0, count: helloBytes.count) // allocate buffer
let numberOfReadBytes = try client.read(&buffer, size: helloBytes.count)
print(numberOfReadBytes == helloBytes.count) // true
print(buffer == helloBytes) // true
client.close()
}
catch {
print(error)
}
Server Side
do {
let server = try Socket(.inet, type: .stream, protocol: .tcp) // create server socket
do {
try server.set(option: .reuseAddress, true) // set SO_REUSEADDR to 1
}
catch {
print(error)
}
do {
try server.bind(port: 8080, address:"192.168.1.88" ) // bind 'localhost:8090' address to the socket
}
catch {
print(error)
}
do {
try server.listen() // allow incoming connections
}
catch {
print(error)
}
// server.close()
let clientAtServerside = try server.accept() // accept client connection
try clientAtServerside.write(helloBytes) // sending bytes to the client
clientAtServerside.close()
}
catch {
print(error)
}
Please kindly provide the solution for this.
Extension com.ribencong.blockchainPipe.TunProxy died unexpectedly
[TunProxy:75295] SyscallError: setpriority(PRIO_DARWIN_ROLE, 75295, 3): No such process
[TunProxy:75295] Remove assertion: <BKProcessAssertion: 0x100d7d6c0; "com.apple.extension.session" (extension:inf); id:โฆ85104422BD2F>
-CMSessionMgr- CMSessionMgrHandleApplicationStateChange: CMSession: Client com.ribencong.blockchainPipe.TunProxy with pid '75295' is now Background Running. Background entitlement: NO LongFormVideoApp: NO
1177: pid 75295(TunProxy)
Hello,
the project seem to not be able to compile in ubuntu 16.04, using Swift 4.1
libressl cannot be installed.
swift build report several error around CLibreSSL
Hi and thanks for your great job.
I have a nodejs client which sends messages to the server part. I use your work to create the server part. I need to listen incoming messages in my swift app. With delegate? Thanks a lot in advance!
pod install gets the error.
Podfile is:
source 'https://github.com/CocoaPods/Specs.git'
target 'SocketSwift' do
pod 'Socket.swift', '~> 2.4.0'
end
Code is unmodified Socket.swift
Full screen shot on Stackoverflow:
apple documentation reads that POSIX sockets will not activate the cellular radio... but I read things on stackoverflow saying it does (users had succesfully accomplished it)... then another user said the radio died after a little bit, with others being surprised.
do you have any final word on this, given this library exists? thanks!
please make an example that socket server wait for a client to connect and have a conversation like a chat room with multi user!
Hi, Thank you very much for the libraries Socket.swift and HTTP.swift.
I need to generate the certificate used by the HTTP server (and thus the TLS.swift file used in Socket.swift) at runtime. That is to say I need to generate a new certificate everytime the app is launched and I start up the server.
Do you know of any way that this can be achieved on iOS?
I have searched far and wide and it seems most people end up shipping a copy of OpenSSL in their app to do this. I am guessing that if I ended up doing this, then I would need export compliance and sign off from the US government / Apple to do this.
Until now it worked perfectly for me, but since the iOS 15.4 version I can't connect to the TCP server.
The error is: SocketError 4: Interrupted system call
(If I try with an iPhone with iOS 15.2, it works)
i get a warning if i try to build my project
warning: you may be able to install libtls using your system-packager:
apt-get install libressl
installing apt-get install libressl
does not find the package
errors on building
.build/checkouts/CLibreSSL/clibressl.h:4:10: error: 'tls.h' file not found
.build/checkouts/Socket.swift/Sources/TLS.swift:12:12: error: could not build C module 'CLibreSSL'
I need to set a timeout for the connect function but i have found only a timeout for the read and write function.
I've encountered an upload issue to TestFlight using Fastlane's pilot tool in combination with Xcode 15. The error occurs specifically with the SocketSwift.xcframework included in my application. During the upload process, asset validation fails with an error indicating that the Info.plist within SocketSwift.xcframework is missing the required CFBundleVersion key.
Asset validation failed (90056) This bundle Payload/<my-app.app>/Frameworks/SocketSwift.framework is invalid.
The Info.plist file is missing the required key: CFBundleVersion.
Please find more information about CFBundleVersion at
https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleversion (ID: 5f353f23-4add-481b-8e2c-2c443a55dc26)
how to take socket connected to server socket adress?
func echoService(client: TCPClient) {
print("Newclient from:\(client.address)[\(client.port)]") // I need that Like code !
var d = client.read(1024*10)
client.send(data: d!)
client.close()
}
func testServer() {
let server = TCPServer(address: "127.0.0.1", port: 8080)
switch server.listen() {
case .success:
while true {
if var client = server.accept() {
echoService(client: client)
} else {
print("accept error")
}
}
case .failure(let error):
print(error)
}
}
Thanks for this great package. I'm using this on Linux.
What's the best way to get the remote socket address after the accept
returns?
I want to read an image data from socket to me. How can I do that?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.