Twitch SDK (Internal)
winsocket.h
Go to the documentation of this file.
1 /********************************************************************************************
2 * Twitch Broadcasting SDK
3 *
4 * This software is supplied under the terms of a license agreement with Twitch Interactive, Inc. and
5 * may not be copied or used except in accordance with the terms of that agreement
6 * Copyright (c) 2012-2016 Twitch Interactive, Inc.
7 *********************************************************************************************/
8 
9 #pragma once
10 
13 #include "twitchsdk/core/socket.h"
14 
15 #include <array>
16 
17 
18 namespace ttv
19 {
20  class WinSocket;
21  class WinSocketFactory;
22  class SecureWinSocketFactory;
23 }
24 
25 
26 class ttv::WinSocket : public ISocket
27 {
28 public:
29  WinSocket();
30  virtual ~WinSocket();
31 
32  TTV_ErrorCode Initialize(const std::string& host, const std::string& port);
33  TTV_ErrorCode TCPListen(const std::string& host, const std::string& port);
34  TTV_ErrorCode AcceptConnection(std::shared_ptr<ISocket>& newSocket);
35 
36  // ISocket implementation
37  virtual TTV_ErrorCode Connect();
38  virtual TTV_ErrorCode Disconnect();
39  virtual TTV_ErrorCode Send(const uint8_t* buffer, size_t length, size_t& sent);
40  virtual TTV_ErrorCode Recv(uint8_t* buffer, size_t length, size_t& received);
41  virtual uint64_t TotalSent();
42  virtual uint64_t TotalReceived();
43  virtual bool Connected();
44 
47 
48 private:
49  TTV_ErrorCode SetBlockingMode(bool block);
50 
51  std::string mHost;
52  std::string mPort;
53  size_t mSocket;
55  uint64_t mTotalSent;
56  uint64_t mTotalReceived;
57 };
58 
59 
61 {
62 public:
63  virtual ~WinSocketFactory();
64  virtual bool IsProtocolSupported(const std::string& protocol);
65  virtual TTV_ErrorCode CreateSocket(const std::string& uri, std::shared_ptr<ISocket>& result);
66 };
std::string mHost
Definition: winsocket.h:51
TTV_ErrorCode CreateSocket(const std::string &uri, std::shared_ptr< ISocket > &result)
TTV_ErrorCode AcceptConnection(std::shared_ptr< ISocket > &newSocket)
uint64_t mTotalSent
Definition: winsocket.h:55
virtual TTV_ErrorCode Disconnect()
virtual TTV_ErrorCode Recv(uint8_t *buffer, size_t length, size_t &received)
size_t mSocket
Definition: winsocket.h:53
uint64_t mTotalReceived
Definition: winsocket.h:56
virtual uint64_t TotalReceived()
JSON (JavaScript Object Notation).
Definition: adsapi.h:16
Definition: winsocket.h:26
virtual ~WinSocket()
Definition: winsocket.h:60
std::string mPort
Definition: winsocket.h:52
TTV_ErrorCode TCPListen(const std::string &host, const std::string &port)
int mLastSocketError
Definition: winsocket.h:54
virtual bool Connected()
TTV_ErrorCode Initialize(const std::string &host, const std::string &port)
uint32_t TTV_ErrorCode
Definition: errortypes.h:30
virtual uint64_t TotalSent()
TTV_ErrorCode SetBlockingMode(bool block)
Definition: socket.h:181
static TTV_ErrorCode ShutdownWinSock()
Definition: socket.h:405
virtual TTV_ErrorCode Send(const uint8_t *buffer, size_t length, size_t &sent)
static TTV_ErrorCode InitializeWinSock()
virtual TTV_ErrorCode Connect()