X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Examples%2FTCPClientServer%2Fclient.cc;fp=Examples%2FTCPClientServer%2Fclient.cc;h=0297c4185237815542328b32147b6fbd0ec51836;hb=52dcdfccdc3c371bc9d884935ad348755fd38e55;hp=0000000000000000000000000000000000000000;hpb=fbb92f7d46961a9994ff74703f470c36654fb2be;p=senf.git diff --git a/Examples/TCPClientServer/client.cc b/Examples/TCPClientServer/client.cc new file mode 100644 index 0000000..0297c41 --- /dev/null +++ b/Examples/TCPClientServer/client.cc @@ -0,0 +1,53 @@ +// $Id$ +// +// Copyright (C) 2007 +// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) +// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + +// Custom includes +#include +#include +#include "Socket/TCPSocketHandle.hh" +#include "Socket/INetAddressing.hh" +#include "Packets/EthernetPacket.hh" + + +int main(int argc, char const * argv[]) +{ + try { + for (int i=0; i<=1000; i++) { + senf::TCPv4ClientSocketHandle sock; + sock.connect(senf::INet4Address("127.0.0.1", 4243)); + sock.protocol().linger(true); + + std::stringstream s; + s << i++; + sock.write(s.str()); + + sock.close(); + + std::cout << i << std::endl; + } + } + catch (std::exception const & ex) { + std::cerr << senf::prettyName(typeid(ex)) << ": " << ex.what() << "\n"; + } + + return 0; +}