?? exserver.java
字號:
package exframework;
/**
* <p>Title: ExFramework</p>
*
* <p>Description: lizhenpeng</p>
*
* <p>Copyright: Copyright (c) 2005</p>
*
* <p>Company: LP&P</p>
*
* @author lipeng
* @version 1.0
*/
import javax.microedition.io.*;
import java.io.*;
import javax.microedition.lcdui.*;
public class ExServer implements AllAction
{
ServerSocketConnection server;
SocketConnection client;
byte []readBuffer;
byte []writeBuffer;
public ExServer()
{
readBuffer = new byte[4];
}
public void allAction(MainForm form)
{
try
{
server=(ServerSocketConnection)Connector.open("socket://:8070");
client=(SocketConnection)server.acceptAndOpen();
client.setSocketOption(SocketConnection.DELAY,0); //是否開啟Nagle算法
client.setSocketOption(SocketConnection.LINGER,5); //設(shè)置服務(wù)器的懸掛等待時(shí)間
client.setSocketOption(SocketConnection.KEEPALIVE,0);
client.setSocketOption(SocketConnection.RCVBUF,1024); //設(shè)置接收緩沖
client.setSocketOption(SocketConnection.SNDBUF,1024); //設(shè)置發(fā)送緩沖
InputStream is=client.openInputStream();
OutputStream os=client.openOutputStream();
is.read(readBuffer,0,readBuffer.length);
InputStream imageIn=getClass().getResourceAsStream("/bg.png");
int imageSize = imageIn.available();
byte[]imageBuffer = new byte[imageSize];
imageIn.read(imageBuffer,0,imageSize);
ByteArrayOutputStream bos=new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
dos.writeInt(imageSize);
dos.flush();
writeBuffer = bos.toByteArray();
os.write(writeBuffer,0,writeBuffer.length);
os.write(imageBuffer,0,imageSize);
os.flush();
}
catch(Exception e)
{
System.out.print(e);
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -