English 中文(简体)
阅读和书写
原标题:reading and writing from sockets

我们重建了每个客户服务器的星座,并陷入了问题。 我们希望永远准备好读写或写。 目前,我们采用正在阻碍的袖珍读法,因此,我们不能发出任何书面要求。

  • is there a way to interrupt the read operation?
  • perhaps it s better to have the main server thread responsible for writing to the socket?

如果是的话,它是否仍然符合每个客户设计模式的校对?

最佳回答

或许,你应当使用单独的透镜,一只读,一只书写,使用某种同步方法(例如,与双向透镜共用缓冲器),在两者之间进行沟通。 此外,<条码>选取 可使用电话了解是否有任何数据有待填写。

<>Update>

最初,我想到的是<代码>选择()功能,可向C. Oh well打电话。

我在贾瓦森文中可以发现的最近一点是: > 代码>Socket.getInputStream(>,这使你有一个可以测试的溪流,以确定是否有tes可供阅读或无法从背书上查阅。

问题回答

使用同步(非锁定)的IO。 或者,你也可以使用单独的读写法。

保证记要不是锁定的(我认为FIONBIO)。 并且使用<条码>电子数据来确定数据何时可以读。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签