Comments (18)
Could you provide a minimum example to reproduce it? Thanks.
from bluesocket.
I used the testReadWrite method in dome, normal data can be received, but long data cannot be received
from bluesocket.
我的代码.zip
这是我的代码
from bluesocket.
Hello, what's the matter with my question? Can it be solved?
from bluesocket.
@ShineYangGod I'm not sure what you mean by "long data".
I've replaced the line in SocketTests.testReadWrite
by:
// let hello = "Hello from client..."
let hello = String(repeating: "Hello from client...", count: 1000)
and everything works fine.
If your use case is different, please provide a minimum example that we can look at.
from bluesocket.
Wait a minute, I will give you a long data example
from bluesocket.
MintBlueTCPSocketMangent.swift.zip
This is what I use now, and finally there is an example of the data returned by our gateway
from bluesocket.
If I'm using the data (end of your doc) directly in the sample, it works fine. I think the issue should be somewhere else, either in the setup or in the delay induced by your gateway maybe?
from bluesocket.
If i directly use SocketTests.testReadWrite Is it possible to connect to TCP and send data and receive data?
from bluesocket.
from bluesocket.
I tested it several times, and it seems that the client stopped receiving after receiving a few pieces of data. How do I set the client to continue to receive data?
from bluesocket.
After testing, our gateway is no problem. I tried other third-party sockets, and there is no problem. Now, when we use our socket to receive messages, we can’t achieve continuous reception.
Our gateway will generally return two messages in a row, and will actively push the message. When I send a message, the gateway is pushing at the same time, and the message will not be received at this time.
from bluesocket.
@ShineYangGod This sounds similar to this issue. TCP sockets can operate in a blocking or non-blocking fashion. When using non-blocking (which I think is the default), you are not guaranteed to get any specific number of bytes upon read. So when you run things locally you might see that you get all your data instantaneously, but when you go through any router, your data may be "chunked" in an arbitrary way. You can read more details in this Stack Overflow discussion as well.
from bluesocket.
Can you give a specific example?
from bluesocket.
Why is the tcp connection so slow? And the message sent to the server is very slow. I have no problem with other sockets, and I looked at the log and did not receive the message sent.
from bluesocket.
Hi @ShineYangGod can you provide a working example? I'm looking at the MintBlueTCPSocketMangent.swift.zip
you gave and it looks like your server in mintServerHelper()
is accepting new connections but not reading or writing any data. Meanwhile your client in mintTestReadWrite()
is attempting to read data as soon as it's connected... I'm not sure if the socket is a blocking or non-blocking socket...
If the client socket is blocking, then the first mintReadAndPrint()
on line 125 will just block until timeout before you write.
If the client socket is non-blocking, then socket.write()
on line 127 may potentially be incomplete.
So either way I think there are issues with your socket handling.
from bluesocket.
Hi @ShineYangGod can you provide a working example? I'm looking at the MintBlueTCPSocketMangent.swift.zip
you gave and it looks like your server in mintServerHelper()
is accepting new connections but not reading or writing any data. Meanwhile your client in mintTestReadWrite()
is attempting to read data as soon as it's connected... I'm not sure if the socket is a blocking or non-blocking socket...
If the client socket is blocking, then the first mintReadAndPrint()
on line 125 will just block until timeout before you write.
If the client socket is non-blocking, then socket.write()
on line 127 may potentially be incomplete.
So either way I think there are issues with your socket handling.
from bluesocket.
MintBlueTCPSocketMangent.swift.zip
I'm not sure what this method is for? acceptClientConnection, whenever you get to this step, it will jump out, attach my code
from bluesocket.
Related Issues (20)
- Socket listen failed on iOS 14.0.1 HOT 7
- Is it possible observe connection with client? HOT 1
- Error code: -9980(0x-26FC), No route to host HOT 12
- 'listen' function unable to bind address HOT 2
- Download multiple files HOT 2
- Warnings in Xcode 13 HOT 10
- Cannot connect to listening UNIX socket HOT 6
- Error code: -9993(0x-2709), Invalid argument HOT 6
- Get local IP address HOT 1
- Echoserver and JavaScript HOT 3
- Can not receive tcp packets in hotspot HOT 1
- Tcp Incomplete receiving data HOT 1
- Unable to detect closed socket HOT 3
- Incompatible with swift-argument-parser v1.0.0+ HOT 9
- is there any other
- Reading Less than SOCKET_MINIMUM_READ_BUFFER_SIZE? HOT 1
- A shell task failed with exit code 72 HOT 1
- Task failed with exit code 70
- Postman can not connect to the Example EchoServer
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bluesocket.