Source Code Cross Referenced for ICPSender.java in  » Web-Server » Jigsaw » org » w3c » www » protocol » http » icp » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Server » Jigsaw » org.w3c.www.protocol.http.icp 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // ICPSender.java
002:        // /$Id: ICPSender.java,v 1.4 2000/08/16 21:38:04 ylafon Exp $
003:        // (c) COPYRIGHT MIT and INRIA, 1996.
004:        // please first read the full copyright statement in file COPYRIGHT.HTML
005:
006:        package org.w3c.www.protocol.http.icp;
007:
008:        import java.net.DatagramPacket;
009:        import java.net.DatagramSocket;
010:        import java.net.InetAddress;
011:        import java.net.SocketException;
012:        import java.net.URL;
013:
014:        import java.io.IOException;
015:
016:        class ICPSender {
017:            /**
018:             * The filter we are attached to.
019:             */
020:            protected ICPFilter filter = null;
021:            /**
022:             * Our target host address.
023:             */
024:            protected InetAddress addr = null;
025:            /**
026:             * Our target port number.
027:             */
028:            protected int port = -1;
029:            /**
030:             * The HTTP service provided by the target ICP host.
031:             */
032:            protected URL proxy = null;
033:            /**
034:             * The buffer to emit messages.
035:             */
036:            protected byte buffer[] = null;
037:
038:            /**
039:             * Return a String representation of this sender.
040:             * @return A String.
041:             */
042:
043:            public String toString() {
044:                return getAddress() + "/" + getPort();
045:            }
046:
047:            /**
048:             * Get the HTTP service location of that sender.
049:             * @return The HTTP service location, as a URL.
050:             */
051:
052:            public final URL getProxyLocation() {
053:                return proxy;
054:            }
055:
056:            /**
057:             * Get the ICP address for this neighbor.
058:             * @return An InetAddress instance.
059:             */
060:
061:            public final InetAddress getAddress() {
062:                return addr;
063:            }
064:
065:            /**
066:             * Get the port number for that sender target.
067:             * @return An integer port number.
068:             */
069:
070:            public final int getPort() {
071:                return port;
072:            }
073:
074:            /**
075:             * Send the given ICP message to our target host.
076:             * @param msg The ICP message to send.
077:             * @return A boolean, <strong>true</strong> if message was emitted.
078:             */
079:
080:            public boolean send(ICPMessage msg) {
081:                // Encode the message in a byte array:
082:                int len = msg.toByteArray(buffer);
083:                if (len < 0) {
084:                    buffer = new byte[-len + 1];
085:                    len = msg.toByteArray(buffer);
086:                }
087:                // Wrap it up in a datagram:
088:                DatagramPacket p = new DatagramPacket(buffer, len, addr, port);
089:                try {
090:                    filter.getSocket().send(p);
091:                    return true;
092:                } catch (IOException ex) {
093:                }
094:                // FIXME Should mark that host down
095:                return false;
096:            }
097:
098:            /**
099:             * Create a ICPSender to query the given host.
100:             * @param addr The InetAddress of the ICP host.
101:             * @param port The port number it is listening on.
102:             * @exception SocketException If we couldn't create the datagram socket.
103:             */
104:
105:            ICPSender(ICPFilter filter, int srcport, InetAddress addr,
106:                    int dstport, URL proxy) throws SocketException {
107:                this .filter = filter;
108:                this .addr = addr;
109:                this .port = dstport;
110:                this .proxy = proxy;
111:                this .buffer = new byte[512];
112:            }
113:
114:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.