I have a problem getting this to work. Server only recieves half of the data being sent. Whats wrong

Dependencies:   mbed

Committer:
tax
Date:
Tue Mar 29 13:20:15 2011 +0000
Revision:
0:66300c77c6e9

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tax 0:66300c77c6e9 1
tax 0:66300c77c6e9 2 /*
tax 0:66300c77c6e9 3 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
tax 0:66300c77c6e9 4
tax 0:66300c77c6e9 5 Permission is hereby granted, free of charge, to any person obtaining a copy
tax 0:66300c77c6e9 6 of this software and associated documentation files (the "Software"), to deal
tax 0:66300c77c6e9 7 in the Software without restriction, including without limitation the rights
tax 0:66300c77c6e9 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
tax 0:66300c77c6e9 9 copies of the Software, and to permit persons to whom the Software is
tax 0:66300c77c6e9 10 furnished to do so, subject to the following conditions:
tax 0:66300c77c6e9 11
tax 0:66300c77c6e9 12 The above copyright notice and this permission notice shall be included in
tax 0:66300c77c6e9 13 all copies or substantial portions of the Software.
tax 0:66300c77c6e9 14
tax 0:66300c77c6e9 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
tax 0:66300c77c6e9 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
tax 0:66300c77c6e9 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
tax 0:66300c77c6e9 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
tax 0:66300c77c6e9 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
tax 0:66300c77c6e9 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
tax 0:66300c77c6e9 21 THE SOFTWARE.
tax 0:66300c77c6e9 22 */
tax 0:66300c77c6e9 23
tax 0:66300c77c6e9 24 /** \file
tax 0:66300c77c6e9 25 DNS Request header file
tax 0:66300c77c6e9 26 */
tax 0:66300c77c6e9 27
tax 0:66300c77c6e9 28 #ifndef DNSREQUEST_H
tax 0:66300c77c6e9 29 #define DNSREQUEST_H
tax 0:66300c77c6e9 30
tax 0:66300c77c6e9 31 #include "core/net.h"
tax 0:66300c77c6e9 32 #include "core/ipaddr.h"
tax 0:66300c77c6e9 33 #include "core/host.h"
tax 0:66300c77c6e9 34 //Essentially it is a safe interface to NetDnsRequest
tax 0:66300c77c6e9 35
tax 0:66300c77c6e9 36 ///DNS Request error codes
tax 0:66300c77c6e9 37 enum DNSRequestErr
tax 0:66300c77c6e9 38 {
tax 0:66300c77c6e9 39 __DNS_MIN = -0xFFFF,
tax 0:66300c77c6e9 40 DNS_SETUP, ///<DNSRequest not properly configured
tax 0:66300c77c6e9 41 DNS_IF, ///<Interface has problems, does not exist or is not initialized
tax 0:66300c77c6e9 42 DNS_MEM, ///<Not enough mem
tax 0:66300c77c6e9 43 DNS_INUSE, ///<Interface / Port is in use
tax 0:66300c77c6e9 44 DNS_PROCESSING, ///<Request has not completed
tax 0:66300c77c6e9 45 //...
tax 0:66300c77c6e9 46 DNS_OK = 0 ///<Success
tax 0:66300c77c6e9 47 };
tax 0:66300c77c6e9 48
tax 0:66300c77c6e9 49 ///DNS Request Result Events
tax 0:66300c77c6e9 50 enum DNSReply
tax 0:66300c77c6e9 51 {
tax 0:66300c77c6e9 52 DNS_PRTCL,
tax 0:66300c77c6e9 53 DNS_NOTFOUND, ///Hostname is unknown
tax 0:66300c77c6e9 54 DNS_ERROR, ///Problem with DNS Service
tax 0:66300c77c6e9 55 //...
tax 0:66300c77c6e9 56 DNS_FOUND,
tax 0:66300c77c6e9 57 };
tax 0:66300c77c6e9 58
tax 0:66300c77c6e9 59 class NetDnsRequest;
tax 0:66300c77c6e9 60 enum NetDnsReply;
tax 0:66300c77c6e9 61
tax 0:66300c77c6e9 62 ///This is a simple DNS Request class
tax 0:66300c77c6e9 63 /**
tax 0:66300c77c6e9 64 This class exposes an API to deal with DNS Requests
tax 0:66300c77c6e9 65 */
tax 0:66300c77c6e9 66 class DNSRequest
tax 0:66300c77c6e9 67 {
tax 0:66300c77c6e9 68 public:
tax 0:66300c77c6e9 69 ///Creates a new request
tax 0:66300c77c6e9 70 DNSRequest();
tax 0:66300c77c6e9 71
tax 0:66300c77c6e9 72 ///Terminates and closes request
tax 0:66300c77c6e9 73 ~DNSRequest();
tax 0:66300c77c6e9 74
tax 0:66300c77c6e9 75 ///Resolves an hostname
tax 0:66300c77c6e9 76 /**
tax 0:66300c77c6e9 77 @param hostname : hostname to resolve
tax 0:66300c77c6e9 78 */
tax 0:66300c77c6e9 79 DNSRequestErr resolve(const char* hostname);
tax 0:66300c77c6e9 80
tax 0:66300c77c6e9 81 ///Resolves an hostname
tax 0:66300c77c6e9 82 /**
tax 0:66300c77c6e9 83 @param host : hostname to resolve, the result will be stored in the IpAddr field of this object
tax 0:66300c77c6e9 84 */
tax 0:66300c77c6e9 85 DNSRequestErr resolve(Host* pHost);
tax 0:66300c77c6e9 86
tax 0:66300c77c6e9 87 ///Setups callback
tax 0:66300c77c6e9 88 /**
tax 0:66300c77c6e9 89 The callback function will be called on result.
tax 0:66300c77c6e9 90 @param pMethod : callback function
tax 0:66300c77c6e9 91 */
tax 0:66300c77c6e9 92 void setOnReply( void (*pMethod)(DNSReply) );
tax 0:66300c77c6e9 93
tax 0:66300c77c6e9 94 class CDummy;
tax 0:66300c77c6e9 95 ///Setups callback
tax 0:66300c77c6e9 96 /**
tax 0:66300c77c6e9 97 The callback function will be called on result.
tax 0:66300c77c6e9 98 @param pItem : instance of class on which to execute the callback method
tax 0:66300c77c6e9 99 @param pMethod : callback method
tax 0:66300c77c6e9 100 */
tax 0:66300c77c6e9 101 template<class T>
tax 0:66300c77c6e9 102 void setOnReply( T* pItem, void (T::*pMethod)(DNSReply) )
tax 0:66300c77c6e9 103 {
tax 0:66300c77c6e9 104 m_pCbItem = (CDummy*) pItem;
tax 0:66300c77c6e9 105 m_pCbMeth = (void (CDummy::*)(DNSReply)) pMethod;
tax 0:66300c77c6e9 106 }
tax 0:66300c77c6e9 107
tax 0:66300c77c6e9 108 ///Gets IP address once it has been resolved
tax 0:66300c77c6e9 109 /**
tax 0:66300c77c6e9 110 @param pIp : pointer to an IpAddr instance in which to store the resolved IP address
tax 0:66300c77c6e9 111 */
tax 0:66300c77c6e9 112 DNSRequestErr getResult(IpAddr* pIp);
tax 0:66300c77c6e9 113
tax 0:66300c77c6e9 114 ///Closes DNS Request before completion
tax 0:66300c77c6e9 115 DNSRequestErr close();
tax 0:66300c77c6e9 116
tax 0:66300c77c6e9 117 protected:
tax 0:66300c77c6e9 118 void onNetDnsReply(NetDnsReply r);
tax 0:66300c77c6e9 119 DNSRequestErr checkInst();
tax 0:66300c77c6e9 120
tax 0:66300c77c6e9 121 private:
tax 0:66300c77c6e9 122 NetDnsRequest* m_pNetDnsRequest;
tax 0:66300c77c6e9 123
tax 0:66300c77c6e9 124 CDummy* m_pCbItem;
tax 0:66300c77c6e9 125 void (CDummy::*m_pCbMeth)(DNSReply);
tax 0:66300c77c6e9 126
tax 0:66300c77c6e9 127 void (*m_pCb)(DNSReply);
tax 0:66300c77c6e9 128
tax 0:66300c77c6e9 129 };
tax 0:66300c77c6e9 130
tax 0:66300c77c6e9 131 #endif