⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 requestor.java

📁 A byte comunication system made in java that can be used to send messages in betweeen computers on t
💻 JAVA
字号:

package RequestReply;

import Commons.Address;

import java.net.*;
import java.io.*;


public class Requestor
{

	private Socket s;
	private OutputStream oStr;
	private InputStream iStr;
	private String myName;
	public Requestor(String theName) { myName = theName; }


	public byte[] deliver_and_wait_feedback(Address theDest, byte[] data)
	{

		byte[] buffer = null;
		int val;
		try
		{
			s = new Socket(theDest.dest(), theDest.port());
System.out.println("Requestor: Socket"+s);
			oStr = s.getOutputStream();
			oStr.write(data);
			oStr.flush();
			iStr = s.getInputStream();
			val = iStr.read();
			buffer = new byte[val];
			iStr.read(buffer);
			iStr.close();
                        oStr.close();
			s.close();
			}
		catch (IOException e) { 
                       System.out.println("IOException in deliver_and_wait_feedback"); }
		return buffer;
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -