📄 messagesocket.java
字号:
/* * This file was derived from libdissipate, an open source SIP library. The original file * was modified on 1/23/2001. Please see * http://www.div8.net/dissipate for more information. * * Copyright (c) 2000 Billy Biggs <bbiggs@div8.net> * * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Library General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public * License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * *//** * class MessageSocket * * In implementing SIP, it is necessary to support both UDP and TCP transports * simultaneously. @ref MessageSocket, @ref UDPMessageSocket and * @ref TCPMessageSocket provide a framework for objectively discussing the two * types of sockets with a common base class. * * This code has been generated using C2J++ * C2J++ is based on Chris Laffra's C2J (laffra@watson.ibm.com) * Read general disclaimer distributed with C2J++ before using this code * For information about C2J++, send mail to Ilya_Tilevich@ibi.com */package org.mitre.jsip;import java.net.*;public abstract class MessageSocket{ /** * MessageSocket */ public MessageSocket() { type = NONE; } /** * connect * @param portnum * @return int */ public abstract int connect(String hostname, int portnum); /** * Another connect * @param host the host to connect to * @param portnum the port to connect to * @return 0 if successful */ public abstract int connect( InetAddress host, int portnum ); /** * send * @param sendbuffer * @param length * @return int */ public abstract int send(String sendbuffer, int length); /** * receive * @param recvbuffer * @param maxlength * @return int */ public abstract int receive(byte[] recvbuffer, int maxlength); /** * listen * @param portnum * @return int */ public abstract int listen(MessageQueue queue); /** * accept * @return int */ public abstract void accept(); /** * listenOnEvenPort * @return int */ public abstract int listenOnEvenPort(); /** * setHostname * @param hostname * @return bool */ public boolean setHostname(String hostname) { try { localHostIA = InetAddress.getByName( hostname ); } catch (UnknownHostException uhe) { System.err.println( "MessageSocket::setHostname(): gethostbyname() failed" ); return false; } return true; } /** * getFileDescriptor * @return int */ //public int getFileDescriptor() //{ return socketfd; } /** * getSocketType * @return SocketType */ public int getSocketType() { return type; } /** * getPortNumber * @return int */ public int getPortNumber() { return Sip.getLocalPort(); } /** * forcePortNumber * @param newport */ public void forcePortNumber(int newport) { localPort = newport; } /** * close * */ public abstract void close(); // class variables protected int socketfd; protected int type; protected int localPort = 5060; private int buffsize; private String ipaddress; private String hostname; private String callid; private int port; // socket Types public static final int UDP = 0; public static final int TCP = 1; public static final int MCAST = 2; public static final int NONE = 3; // For hostenv protected InetAddress remoteHostIA; protected InetAddress localHostIA;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -