/usr/share/cruisecontrol-bin-2.6.1/projects/qpid-trunk/cpp/src/qpid/sys/Socket.h

00001 #ifndef _sys_Socket_h
00002 #define _sys_Socket_h
00003 
00004 /*
00005  *
00006  * Licensed to the Apache Software Foundation (ASF) under one
00007  * or more contributor license agreements.  See the NOTICE file
00008  * distributed with this work for additional information
00009  * regarding copyright ownership.  The ASF licenses this file
00010  * to you under the Apache License, Version 2.0 (the
00011  * "License"); you may not use this file except in compliance
00012  * with the License.  You may obtain a copy of the License at
00013  * 
00014  *   http://www.apache.org/licenses/LICENSE-2.0
00015  * 
00016  * Unless required by applicable law or agreed to in writing,
00017  * software distributed under the License is distributed on an
00018  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
00019  * KIND, either express or implied.  See the License for the
00020  * specific language governing permissions and limitations
00021  * under the License.
00022  *
00023  */
00024 #include <string>
00025 #include "qpid/sys/Time.h"
00026 
00027 struct sockaddr;
00028 
00029 namespace qpid {
00030 namespace sys {
00031 
00032 class SocketPrivate;
00033 class Socket
00034 {
00035         friend class Poller;
00036 
00037         SocketPrivate* const impl;
00038 
00039 public:
00041     Socket();
00042     ~Socket();
00043 
00045     void createTcp() const;
00046     
00048     void setTimeout(const Duration& interval) const;
00049     
00051     void setNonblocking() const;
00052 
00053     void connect(const std::string& host, int port) const;
00054 
00055     void close() const;
00056 
00057     enum { SOCKET_TIMEOUT=-2, SOCKET_EOF=-3 } ErrorCode;
00058 
00060     ssize_t send(const void* data, size_t size) const;
00061 
00066     ssize_t recv(void* data, size_t size) const;
00067 
00073     int listen(int port = 0, int backlog = 10) const;
00074     
00078     std::string getSockname() const;
00079 
00083     std::string getPeername() const;
00084 
00089     std::string getPeerAddress() const;
00094     std::string getLocalAddress() const;
00095 
00096     uint16_t getLocalPort() const;
00097     uint16_t getRemotePort() const;
00098 
00099     
00103     Socket* accept(struct sockaddr *addr, socklen_t *addrlen) const;
00104 
00105     // TODO The following are raw operations, maybe they need better wrapping? 
00106     int read(void *buf, size_t count) const;
00107     int write(const void *buf, size_t count) const;
00108 
00109     int toFd() const;
00110     
00111 private:
00112         Socket(SocketPrivate*);
00113 };
00114 
00115 }}
00116 #endif  

Generated on Thu Apr 10 11:08:18 2008 for Qpid by  doxygen 1.4.7