List of usage examples for java.net SocketException getMessage
public String getMessage()
From source file:watch.oms.omswatch.actioncenter.helpers.WatchTransDBParser.java
@SuppressWarnings("unused") private String fetchURLConnectionConfigResponse(String serviceURL) { String traceType = OMSApplication.getInstance().getTraceType(); OMSApplication.getInstance().setTraceType(OMSConstants.TRACE_TYPE_SERVER); // AppMonitor /*analyzer.startNetworkConnection(serviceURL, OMSMessages.CONNECTION_PREFIX.getValue() + connectionID);*///from w ww . j a v a 2 s . c om ActionCenterHelper actionCenterHelper = new ActionCenterHelper(appContext); String configResponse = null; String response = ""; InputStream inputStream = null; HttpURLConnection urlConnection = getHttpURLConnection(serviceURL); try { urlConnection.connect(); } catch (SocketException e) { Log.e(TAG, "SocketException occurred while excecuting the Trans Service." + e.getMessage()); e.printStackTrace(); configResponse = OMSMessages.ACTION_CENTER_FAILURE.getValue(); } catch (IOException e) { Log.e(TAG, "IOException occurred while while excecuting the Trans Service." + e.getMessage()); e.printStackTrace(); configResponse = OMSMessages.ACTION_CENTER_FAILURE.getValue(); } catch (Exception e) { Log.e(TAG, "Exception occurred while while excecuting the Trans Service." + e.getMessage()); e.printStackTrace(); configResponse = OMSMessages.ACTION_CENTER_FAILURE.getValue(); } if (urlConnection != null) { // AppMonitor //analyzer.updateConnectionStatus(connectionID, true); try { int statusCode = urlConnection.getResponseCode(); if (statusCode == OMSConstants.STATUSCODE_OK) { inputStream = new BufferedInputStream(urlConnection.getInputStream()); response = convertStreamToString(inputStream); Log.d(TAG, "GETBL Response for HTTPURLConnection:::" + response); // Create a Reader from String // configResponse = transDBParser(response); Reader stringReader = new StringReader(response); readJsonStream(stringReader); ContentValues contentValues = new ContentValues(); contentValues.put(OMSDatabaseConstants.TRANSACTION_QUEUE_TYPE, OMSDatabaseConstants.GET_TYPE_REQUEST); contentValues.put(OMSDatabaseConstants.TRANSACTION_QUEUE_STATUS, OMSDatabaseConstants.ACTION_STATUS_FINISHED); contentValues.put(OMSDatabaseConstants.TRANSACTION_QUEUE_SERVER_URL, serviceURL); contentValues.put(OMSDatabaseConstants.TRANSACTION_QUEUE_DATA_TABLE_NAME, tableName); actionCenterHelper.insertOrUpdateTransactionFailQueue(contentValues, uniqueRowId, configAppId); // AppMonitor /*analyzer.receivedConnectionResponse(connectionID, urlConnection.getContentLength(), OMSDatabaseConstants.GET_TYPE_REQUEST);*/ /* ServerDBUpdateHelper dbhelper = new ServerDBUpdateHelper(appContext); dbhelper.insertCallTraceTypeData(ConsoleDBConstants.CALL_TRACE_TYPE_TABLE, ""+OMSApplication.getInstance().getAppId());*/ /* Log.i(TAG, "Server URL::"+serviceURL); Log.i(TAG, "Server Response time::"+OMSApplication.getInstance().getServerProcessDuration()); */ Log.i(TAG, "ServerTime::" + OMSApplication.getInstance().getServerProcessDuration() + "\t" + "DBTime::" + OMSApplication.getInstance().getDatabaseProcessDuration() + "\t" + serviceURL); OMSApplication.getInstance().setTraceType(traceType); configResponse = OMSMessages.BL_SUCCESS.getValue(); } else { Log.e(TAG, "status code[" + urlConnection.getResponseCode() + "] Reason[" + urlConnection.getResponseMessage() + "]"); configResponse = OMSMessages.ACTION_CENTER_FAILURE.getValue(); ContentValues contentValues = new ContentValues(); contentValues.put(OMSDatabaseConstants.TRANSACTION_QUEUE_STATUS, OMSDatabaseConstants.ACTION_STATUS_TRIED); contentValues.put(OMSDatabaseConstants.TRANSACTION_QUEUE_TYPE, OMSDatabaseConstants.GET_TYPE_REQUEST); contentValues.put(OMSDatabaseConstants.TRANSACTION_QUEUE_SERVER_URL, serviceURL); contentValues.put(OMSDatabaseConstants.TRANSACTION_QUEUE_DATA_TABLE_NAME, tableName); actionCenterHelper.insertOrUpdateTransactionFailQueue(contentValues, uniqueRowId, configAppId); inputStream = new BufferedInputStream(urlConnection.getInputStream()); // AppMonitor /*analyzer.receivedConnectionResponse(connectionID, urlConnection.getContentLength(), OMSDatabaseConstants.GET_TYPE_REQUEST);*/ response = convertStreamToString(inputStream); if (response != null) { return configResponse; } else { try { JSONObject jsonObject = new JSONObject(); jsonObject.put(OMSMessages.ERROR.getValue(), urlConnection.getResponseCode()); jsonObject.put(OMSMessages.ERROR_DESCRIPTION.getValue(), urlConnection.getResponseMessage()); response = jsonObject.toString(); } catch (JSONException e) { Log.e(TAG, "JSONException occurred when is ConfigDBParse Failed." + e.getMessage()); e.printStackTrace(); } } } } catch (SocketException e) { Log.e(TAG, "SocketException occurred while excecuting the Trans Service." + e.getMessage()); e.printStackTrace(); configResponse = OMSMessages.ACTION_CENTER_FAILURE.getValue(); } catch (IOException e) { Log.e(TAG, "IOException occurred while while excecuting the Trans Service." + e.getMessage()); e.printStackTrace(); configResponse = OMSMessages.ACTION_CENTER_FAILURE.getValue(); } catch (Exception e) { Log.e(TAG, "Exception occurred while while excecuting the Trans Service." + e.getMessage()); e.printStackTrace(); configResponse = OMSMessages.ACTION_CENTER_FAILURE.getValue(); } } else { configResponse = OMSMessages.ACTION_CENTER_FAILURE.getValue(); } return configResponse; }
From source file:com.microsoft.tfs.core.ws.runtime.client.SOAPService.java
private void executeSOAPRequestInternal(final SOAPRequest request, final String responseName, final SOAPMethodResponseReader responseReader) throws SOAPFault, UnauthorizedException, ProxyUnauthorizedException, InvalidServerResponseException, EndpointNotFoundException, TransportException, CanceledException { final PostMethod method = request.getPostMethod(); final long start = System.currentTimeMillis(); long serverExecute = -1; long contentLength = -1; int response = -1; boolean isCompressed = false; IOException ioException = null; byte[] responseBytes = null; TraceInputStream responseStream = null; try {// www . ja v a 2 s.c om /* * Our implementation aims to be tolerant of connection resets * caused by half-open sockets. It detects them and retries the * operation once. * * Here's the problem: sometimes IIS's ASP.NET worker process is * recycled (this can happen because of an application pool time * threshold, number of requests served threshold, memory usage * threshold, etc.). When the process is recycled, most sockets that * were connected to it (including client sockets) will continue to * work fine once IIS builds a new worker. Sometimes, however, bad * things happen: those connected sockets will be reset by the * server the first time they're used. * * Since the default TFS configuration (as of RC) is to recycle the * application pool's worker every 29 hours, a user is likely to * have a half-open TCP socket if he leaves his client running * through the night. The client may work correctly, but in the case * that it receives a reset, it is pretty safe to retry the * operation once. * * Some JREs use the string "Connection reset by peer", others use * "Connection reset". We will match both. */ final long serverStart = System.currentTimeMillis(); try { response = client.executeMethod(method); } catch (final SocketException e) { /* * If the user cancelled the current task, we might get a * "socket closed" exception if the HTTPConnectionCanceller * closed the socket after timing out waiting for voluntary * cancel. */ if (TaskMonitorService.getTaskMonitor().isCanceled() && (e.getMessage().startsWith("Socket closed") //$NON-NLS-1$ || e.getMessage().startsWith("Stream closed"))) //$NON-NLS-1$ { throw new CanceledException(); } /* * If this fault was not a TCP connection reset, rethrow it. */ if (e.getMessage().startsWith("Connection reset") == false) //$NON-NLS-1$ { throw e; } log.warn("Retrying invoke after a connection reset", e); //$NON-NLS-1$ /* * Give it one more try on the user's behalf. */ response = client.executeMethod(method); } serverExecute = System.currentTimeMillis() - serverStart; responseStream = getResponseStream(method); isCompressed = responseStream.isCompressed(); switch (response) { case HttpStatus.SC_OK: XMLStreamReader reader = null; try { reader = SOAPService.xmlInputFactory.createXMLStreamReader(responseStream, SOAPRequestEntity.SOAP_ENCODING); /* * Read as far as the SOAP body from the stream. */ final QName envelopeQName = new QName(getDefaultSOAPNamespace(), "Envelope", "soap"); //$NON-NLS-1$ //$NON-NLS-2$ final QName headerQName = new QName(getDefaultSOAPNamespace(), "Header", "soap"); //$NON-NLS-1$ //$NON-NLS-2$ final QName bodyQName = new QName(getDefaultSOAPNamespace(), "Body", "soap"); //$NON-NLS-1$ //$NON-NLS-2$ // Read the envelope. if (reader.nextTag() == XMLStreamConstants.START_ELEMENT && reader.getName().equals(envelopeQName)) { while (reader.nextTag() == XMLStreamConstants.START_ELEMENT) { if (reader.getName().equals(headerQName)) { // Ignore headers for now. XMLStreamReaderHelper.readUntilElementEnd(reader); } else if (reader.getName().equals(bodyQName)) { /* * The first element in the body should be * the desired response element, which we * must find (and read into) before we * delegate to the reader (if there is one). */ if (reader.nextTag() == XMLStreamConstants.START_ELEMENT && reader.getName().getLocalPart().equals(responseName)) { try { if (responseReader != null) { responseReader.readSOAPResponse(reader, responseStream); } } catch (final XMLStreamException e) { throw new InvalidServerResponseException(e); } return; } } } } /* * If we got here, some error happened (we couldn't find * our envelope and body tags). */ throw new InvalidServerResponseException( "The server's response does not seem to be a SOAP message."); //$NON-NLS-1$ } catch (final XMLStreamException e) { final String messageFormat = "The server's response could not be parsed as XML: {0}"; //$NON-NLS-1$ final String message = MessageFormat.format(messageFormat, e.getMessage()); throw new InvalidServerResponseException(message); } finally { if (reader != null) { try { reader.close(); } catch (final XMLStreamException e) { } } } case HttpStatus.SC_UNAUTHORIZED: case HttpStatus.SC_MOVED_TEMPORARILY: /* * This may be an ACS or on-premises authentication failure, * examine the headers. */ examineHeadersForFederatedAuthURL(method); case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED: throw new ProxyUnauthorizedException(client.getHostConfiguration().getProxyHost(), client.getHostConfiguration().getProxyPort(), client.getState().getProxyCredentials(AuthScope.ANY)); case HttpStatus.SC_SERVICE_UNAVAILABLE: /* * An error message may be inside the response, in the * headers. */ examineHeadersForErrorMessage(method); case HttpStatus.SC_INTERNAL_SERVER_ERROR: /* * A SOAP fault may be inside the response. */ examineBodyForFault(method); default: final String messageFormat = "The SOAP endpoint {0} could not be contacted. HTTP status: {1}"; //$NON-NLS-1$ final String message = MessageFormat.format(messageFormat, method.getURI().toString(), Integer.toString(response)); throw new EndpointNotFoundException(message, response); } } catch (final IOException e) { ioException = e; throw new TransportException(e.getMessage(), e); } finally { final long total = System.currentTimeMillis() - start; if (responseStream != null) { try { responseStream.close(); } catch (final IOException e) { ioException = e; } responseBytes = responseStream.getBytes(); contentLength = responseStream.getTotalBytes(); } /* * perform logging */ try { if (log.isDebugEnabled()) { logExtended(method, serverExecute, total, contentLength, isCompressed, responseBytes, ioException); } else { log.info(makeNormalLogEntry(method, serverExecute, total, contentLength, isCompressed)); } } catch (final Throwable t) { /* * don't propogate any errors raised while logging */ log.warn("Error logging SOAP call", t); //$NON-NLS-1$ } method.releaseConnection(); } }
From source file:org.zaproxy.zap.extension.ascanrules.TestSQLInjection.java
private void expressionBasedAttack(String param, String originalParam, String modifiedParamValue, String modifiedParamValueConfirm) throws IOException { // those of you still paying attention will note that if handled as expressions (such as by // a database), these represent the same value. HttpMessage msg = getNewMsg();/*from w w w . j ava 2 s .c om*/ setParameter(msg, param, modifiedParamValue); try { sendAndReceive(msg, false); // do not follow redirects } catch (SocketException ex) { if (log.isDebugEnabled()) log.debug("Caught " + ex.getClass().getName() + " " + ex.getMessage() + " when accessing: " + msg.getRequestHeader().getURI().toString()); return; // Something went wrong, no point continuing } countExpressionBasedRequests++; String modifiedExpressionOutputUnstripped = msg.getResponseBody().toString(); String modifiedExpressionOutputStripped = stripOffOriginalAndAttackParam(modifiedExpressionOutputUnstripped, originalParam, modifiedParamValue); String normalBodyOutput = mResBodyNormalStripped; if (!sqlInjectionFoundForUrl && countExpressionBasedRequests < doExpressionMaxRequests) { // if the results of the modified request match the original query, we may be onto // something. if (modifiedExpressionOutputStripped.compareTo(normalBodyOutput) == 0) { if (this.debugEnabled) { log.debug("Check 4, STRIPPED html output for modified expression parameter [" + modifiedParamValue + "] matched (refreshed) original results for " + refreshedmessage.getRequestHeader().getURI().toString()); } // confirm that a different parameter value generates different output, to minimise // false positives // this time param value will be different to original value and mismatch is // expected in responses of original and this value // Note that the two values are NOT equivalent, and the param value is different to // the original HttpMessage msgConfirm = getNewMsg(); setParameter(msgConfirm, param, modifiedParamValueConfirm); try { sendAndReceive(msgConfirm, false); // do not follow redirects } catch (SocketException ex) { if (log.isDebugEnabled()) log.debug("Caught " + ex.getClass().getName() + " " + ex.getMessage() + " when accessing: " + msgConfirm.getRequestHeader().getURI().toString()); return; // Something went wrong } countExpressionBasedRequests++; String confirmExpressionOutputUnstripped = msgConfirm.getResponseBody().toString(); String confirmExpressionOutputStripped = stripOffOriginalAndAttackParam( confirmExpressionOutputUnstripped, originalParam, modifiedParamValueConfirm); if (confirmExpressionOutputStripped.compareTo(normalBodyOutput) != 0) { // the confirm query did not return the same results. This means that arbitrary // queries are not all producing the same page output. // this means the fact we earier reproduced the original page output with a // modified parameter was not a coincidence // Likely a SQL Injection. Raise it String extraInfo = Constant.messages .getString(MESSAGE_PREFIX + "alert.expressionbased.extrainfo", modifiedParamValue, ""); // raise the alert, and save the attack string for the "Authentication Bypass" // alert, if necessary sqlInjectionAttack = modifiedParamValue; bingo(Alert.RISK_HIGH, Alert.CONFIDENCE_MEDIUM, getName(), getDescription(), null, // url param, sqlInjectionAttack, extraInfo, getSolution(), "", msg); // SQL Injection has been found sqlInjectionFoundForUrl = true; return; } } // bale out if we were asked nicely if (isStop()) { return; } } }
From source file:org.accada.reader.rprm.core.ReaderDevice.java
/** * The constructor of the ReaderDevice. This method takes * the value of PROPERTIES_FILE as the location of the property file. * @throws ReaderProtocolException/* w w w .j av a 2s .c om*/ * "Reader not found", "Failed to read properties file", * "wrong valueTrigger in property file", "wrong edgeTrigger in * property file" */ public ReaderDevice() throws ReaderProtocolException { switch (MessageLayer.mgmtAgentType) { case SNMP: mgmtAgent = SnmpAgent.getInstance(); break; // case ...: } try { ntpServerFinder = new NTPServerFinder(); } catch (SocketException se) { log.error(se.getMessage()); } try { dhcpServerFinder = new DHCPServerFinder(null); } catch (SocketException se) { log.error(se.getMessage()); } reboot(PROPERTIES_FILE, DEFAULT_PROPERTIES_FILE); }
From source file:org.accada.reader.rprm.core.ReaderDevice.java
/** * The constructor of the ReaderDevice.//from www . j a va2 s.c o m * @param propFile * The location of the property file * @throws ReaderProtocolException * "Reader not found", "Failed to read properties file", * "wrong valueTrigger in property file", "wrong edgeTrigger in * property file" */ public ReaderDevice(final String propFile, final String defaultPropFile) throws ReaderProtocolException { switch (MessageLayer.mgmtAgentType) { case SNMP: mgmtAgent = SnmpAgent.getInstance(); break; // case ...: } try { ntpServerFinder = new NTPServerFinder(); } catch (SocketException se) { log.error(se.getMessage()); } try { dhcpServerFinder = new DHCPServerFinder(null); } catch (SocketException se) { log.error(se.getMessage()); } reboot(propFile, defaultPropFile); }
From source file:ProtocolRunner.java
private void udpStartButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_udpStartButtonActionPerformed // handler for Start button for UDP: if(started) { // means a session has already started try{/* w ww. j a va 2 s . c om*/ handleUDPStop(); }catch(IOException ex) { showError(ex.getMessage()); } return; } udpRemoteServer = udpRemoteServerField.getText(); if(udpRemoteServer == null || udpRemoteServer.length() == 0) { showError("Please enter a remote server"); return; } try{ udpClient = ClientFactory.getUDPClientInstance( udpSelectionBox.getSelectedIndex()); udpClient.open(); }catch(SocketException se){ showError(se.getMessage()); return; }catch(IOException ioex){ showError(ioex.getMessage()); return; } // if we come here means we have opened a port started = true; udpStartButton.setText("Stop"); udpSelectionBox.setEnabled(false); jTabbedPane1.setEnabledAt(0, false); try { ProtocolHandler.handleUDPProtocol( udpSelectionBox.getSelectedIndex(), udpClient, this); }catch (IOException io) { showError(io.getMessage()); io.printStackTrace(); } }
From source file:ProtocolRunner.java
/** * This code handles the action events for the Connect button *//*www .ja va 2 s . com*/ private void tcpConnectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tcpConnectButtonActionPerformed // if already connected, simply disconnect if(connected) { try { handleDisconnect(); }catch(IOException e) { showError(e.getMessage()); } return; } // if not connected, try and make a connection String server = serverNameField.getText(); String port = portNumberField.getText(); int portNumber; // check if the port number is a valid number try{ portNumber = Integer.parseInt(port); }catch(NumberFormatException nfe){ showError("Invalid port number: " + port); return; } // some basic checking of data if(server == null || server.trim().length() == 0 || portNumber < 1){ showError("Invalid connection attributes"); return; } // now using the factory create an instance of the client // and connect try{ tcpClient = ClientFactory.getTCPClientInstance( tcpSelectionBox.getSelectedIndex()); tcpClient.connect(server, portNumber); }catch(SocketException se){ showError(se.getMessage()); return; }catch(IOException ioex){ showError(ioex.getMessage()); return; } // if we come here means we have connected connected = true; tcpConnectButton.setText("Disconnect"); tcpSelectionBox.setEnabled(false); jTabbedPane1.setEnabledAt(1, false); try { ProtocolHandler.handleTCPProtocol( tcpSelectionBox.getSelectedIndex(), tcpClient, this); }catch (IOException io) { showError(io.getMessage()); io.printStackTrace(); } }
From source file:org.squidy.nodes.MultiTouch.java
/** * /*ww w. j a va 2s. c o m*/ */ protected void startOSCServer() { try { oscPortOut = new OSCPortOut(InetAddress.getByName(addressOutgoing), portOutgoing); } catch (SocketException e) { throw new ProcessException(e.getMessage(), e); } catch (UnknownHostException e) { throw new ProcessException(e.getMessage(), e); } try { oscPortIn = new OSCPortIn(portIncoming, endian); } catch (SocketException e) { throw new ProcessException(e.getMessage(), e); } oscPortIn.addListener("/tuio/2Dcur", new OSCListener() { /* * (non-Javadoc) * * @see com.illposed.osc.OSCListener#acceptMessages(java.util.Date, * com.illposed.osc.OSCMessage[]) */ public void acceptMessages(Date time, OSCMessage[] messages) { List<DataPosition2D> cursors = new ArrayList<DataPosition2D>(1); int fseq = -1; for (OSCMessage message : messages) { Object[] arguments = message.getArguments(); if ("fseq".equals(arguments[0])) { fseq = (Integer) arguments[1]; // System.out.println(fseq); } } for (OSCMessage message : messages) { Object[] arguments = message.getArguments(); if ("set".equals(arguments[0])) { int sessionId = (Integer) arguments[1]; float x = (Float) arguments[2]; float y = (Float) arguments[3]; float movementVectorX = (Float) arguments[4]; float movementVectorY = (Float) arguments[5]; float motionAcceleration = (Float) arguments[6]; float xFactor = getxEnd() - getxFrom(); x = x * xFactor + getxFrom(); float yFactor = getyEnd() - getyFrom(); y = y * yFactor + getyFrom(); DataPosition2D dataPosition2D = new DataPosition2D(TUIO.class, x, y); dataPosition2D.setAttribute(TUIO_ORIGIN_ADDRESS, "/tuio/2Dcur"); dataPosition2D.setAttribute(DataConstant.FRAME_SEQUENCE_ID, fseq); dataPosition2D.setAttribute(DataConstant.SESSION_ID, sessionId); dataPosition2D.setAttribute(TUIO_MOVEMENT_VECTOR_X, movementVectorX); dataPosition2D.setAttribute(TUIO_MOVEMENT_VECTOR_Y, movementVectorY); dataPosition2D.setAttribute(TUIO_MOTION_ACCELERATION, motionAcceleration); dataPosition2D.setAttribute(SOURCE, getCameraID()); cursors.add(dataPosition2D); } } publish(cursors); } }); oscPortIn.addListener("/tuio/_sxyXYmaPP", new OSCListener() { public void acceptMessages(Date time, OSCMessage[] messages) { List<DataPosition2D> cursors = new ArrayList<DataPosition2D>(1); int fseq = -1; for (OSCMessage message : messages) { Object[] arguments = message.getArguments(); if ("fseq".equals(arguments[0])) { fseq = (Integer) arguments[1]; } } for (OSCMessage message : messages) { Object[] arguments = message.getArguments(); if ("set".equals(arguments[0])) { int sessionId = (Integer) arguments[1]; float x = (Float) arguments[2]; float y = (Float) arguments[3]; float movementVectorX = (Float) arguments[4]; float movementVectorY = (Float) arguments[5]; float motionAcceleration = (Float) arguments[6]; float angleA = (Float) arguments[6]; float handWidth = (Float) arguments[6]; float handHeight = (Float) arguments[6]; DataPosition2D dataPosition2D = new DataPosition2D(TUIO.class, x, y); dataPosition2D.setAttribute(TUIO_ORIGIN_ADDRESS, "/tuio/_sxyXYmaPP"); dataPosition2D.setAttribute(DataConstant.FRAME_SEQUENCE_ID, fseq); dataPosition2D.setAttribute(DataConstant.SESSION_ID, sessionId); dataPosition2D.setAttribute(TUIO_MOVEMENT_VECTOR_X, movementVectorX); dataPosition2D.setAttribute(TUIO_MOVEMENT_VECTOR_Y, movementVectorY); dataPosition2D.setAttribute(TUIO_MOTION_ACCELERATION, motionAcceleration); dataPosition2D.setAttribute(TUIO_ANGLE_A, angleA); dataPosition2D.setAttribute(TUIO_HAND_WIDTH, handWidth); dataPosition2D.setAttribute(TUIO_HAND_HEIGHT, handHeight); cursors.add(dataPosition2D); } } publish(cursors); } }); oscPortIn.addListener("/tuio/_sxyXYma", new OSCListener() { /* * (non-Javadoc) * * @see com.illposed.osc.OSCListener#acceptMessages(java.util.Date, * com.illposed.osc.OSCMessage[]) */ public void acceptMessages(Date time, OSCMessage[] messages) { List<DataPosition2D> cursors = new ArrayList<DataPosition2D>(1); int fseq = -1; for (OSCMessage message : messages) { Object[] arguments = message.getArguments(); if ("fseq".equals(arguments[0])) { fseq = (Integer) arguments[1]; } } for (OSCMessage message : messages) { Object[] arguments = message.getArguments(); if ("set".equals(arguments[0])) { int sessionId = (Integer) arguments[1]; float x = (Float) arguments[2]; float y = (Float) arguments[3]; float movementVectorX = (Float) arguments[4]; float movementVectorY = (Float) arguments[5]; float motionAcceleration = (Float) arguments[6]; float angleA = (Float) arguments[7]; DataPosition2D dataPosition2D = new DataPosition2D(TUIO.class, x, y); dataPosition2D.setAttribute(TUIO_ORIGIN_ADDRESS, "/tuio/_sxyXYma"); dataPosition2D.setAttribute(DataConstant.FRAME_SEQUENCE_ID, fseq); dataPosition2D.setAttribute(DataConstant.SESSION_ID, sessionId); dataPosition2D.setAttribute(TUIO_MOVEMENT_VECTOR_X, movementVectorX); dataPosition2D.setAttribute(TUIO_MOVEMENT_VECTOR_Y, movementVectorY); dataPosition2D.setAttribute(TUIO_MOTION_ACCELERATION, motionAcceleration); dataPosition2D.setAttribute(TUIO_ANGLE_A, angleA); cursors.add(dataPosition2D); } } publish(cursors); } }); oscPortIn.startListening(); }
From source file:davmail.exchange.ews.EwsExchangeSession.java
protected void executeMethod(EWSMethod ewsMethod) throws IOException { try {//from ww w .j ava 2 s. c om ewsMethod.setServerVersion(serverVersion); httpClient.executeMethod(ewsMethod); if (serverVersion == null) { serverVersion = ewsMethod.getServerVersion(); } ewsMethod.checkSuccess(); } catch (SocketException e) { LOGGER.error(e + " " + e.getMessage(), e); throw new EWSException(e + " " + e.getMessage()); } finally { ewsMethod.releaseConnection(); } }
From source file:org.lockss.protocol.LcapDatagramComm.java
void start() { socketInQ = new FifoQueue(); try {/*from w w w . j a v a2 s . com*/ sendSock = sockFact.newSendSocket(); } catch (SocketException e) { log.critical("Can't create send socket", e); } if (multiPort >= 0 && group != null) { try { log.debug("new LcapSocket.Multicast(" + socketInQ + ", " + group + ", " + multiPort); mSock1 = sockFact.newMulticastSocket(socketInQ, group, multiPort); mSock1.start(); log.info("Multicast socket started: " + mSock1); } catch (IOException e) { log.error("Can't create multicast socket", e); } if (verifyMulticast) { try { log.debug("new LcapSocket.Multicast(" + socketInQ + ", " + group + ", " + multiPort); mSock2 = sockFact.newMulticastSocket(socketInQ, group, multiPort); mSock2.start(); log.info("2nd multicast socket started: " + mSock2); } catch (IOException e) { log.warning("Can't create 2nd multicast socket, not detecting multicast spoofing", e); verifyMulticast = false; } } } else { log.error("Multicast group or port not configured, not starting multicast receive"); } if (uniPort >= 0) { try { log.debug("new LcapSocket.Unicast(" + socketInQ + ", " + uniPort); LcapSocket.Unicast lsu = sockFact.newUnicastSocket(socketInQ, uniPort); lsu.start(); uSock = lsu; log.info("Unicast socket started: " + lsu); } catch (IOException e) { log.error("Can't create unicast socket", e); noCommAlert("Can't create unicast socket: " + e.getMessage()); throw new ResourceUnavailableException("Can't bind unicast socket", e); } } else { log.error("Unicast port not configured, not starting unicast receive"); } isMuzzleMulticast = false; lastMulticastTime = TimeBase.nowMs(); ensureQRunner(); }