[Javanetsim-cvs] javaNetSim/core/protocolsuite/tcp_ip Application.java,1.2,1.3 Echo.java,1.2,1.3
Status: Beta
Brought to you by:
darkkey
From: Alexander B. <da...@us...> - 2005-11-19 12:41:07
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16671/core/protocolsuite/tcp_ip Modified Files: Application.java Echo.java Log Message: Index: Application.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Application.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Application.java 19 Nov 2005 11:46:08 -0000 1.2 --- Application.java 19 Nov 2005 12:40:59 -0000 1.3 *************** *** 22,25 **** --- 22,26 ---- protected String sdHost; protected int sdPort; + protected int appType; private int id; *************** *** 27,31 **** /** Creates a new instance of ApplicationProtocol */ ! public Application(ProtocolStack inParentStack, int listenPort){ this.listenPort = listenPort; this.mParentStack = inParentStack; --- 28,32 ---- /** Creates a new instance of ApplicationProtocol */ ! public Application(ProtocolStack inParentStack, int listenPort, int appType){ this.listenPort = listenPort; this.mParentStack = inParentStack; Index: Echo.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Echo.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Echo.java 19 Nov 2005 11:46:08 -0000 1.2 --- Echo.java 19 Nov 2005 12:40:59 -0000 1.3 *************** *** 17,22 **** /** Creates a new instance of Echo */ ! public Echo(ProtocolStack inParentStack, int listenPort) { ! super(inParentStack, listenPort); } --- 17,22 ---- /** Creates a new instance of Echo */ ! public Echo(ProtocolStack inParentStack, int listenPort, int appType) { ! super(inParentStack, listenPort, appType); } *************** *** 50,54 **** */ ! public void Connect(String Host, int port) throws TransportLayerException { sdHost = Host; sdPort = port; --- 50,54 ---- */ ! public void ClientConnect(String Host, int port) throws TransportLayerException { sdHost = Host; sdPort = port; *************** *** 56,59 **** --- 56,70 ---- } + + /** + * This method should be called from UDP when client connects to server + * @author key + * @version v0.01 + */ + public void Connected(String Host, int port){ + sdHost = Host; + sdPort = port; + } + /** * This method disconnects from server. *************** *** 74,78 **** public void SendData(String Data) throws TransportLayerException { ! mParentStack.sendUDP(Data, this, clientPort); //processing the protocol doings. } --- 85,89 ---- public void SendData(String Data) throws TransportLayerException { ! mParentStack.sendUDP(Data, this); //processing the protocol doings. } *************** *** 86,89 **** --- 97,116 ---- public void RecvData(String Data) throws TransportLayerException { //processing the protocol doings. + if(appType == 0){ + //client processing recieve + // printing some ... + Disconnect(); + }else{ + //server processing recieve + SendData(Data); + Close(); + Listen(); + } + } + + + public void SendEcho(String Data, String Host, int port) throws TransportLayerException{ + ClientConnect(Host, port); + SendData(Data); } } |