mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
librtmp: create socket
This commit is contained in:
parent
f8335e2c1f
commit
feaf0c5e89
2 changed files with 29 additions and 3 deletions
|
@ -23,9 +23,32 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#include <srs_lib_simple_socket.hpp>
|
#include <srs_lib_simple_socket.hpp>
|
||||||
|
|
||||||
SimpleSocketStream::SimpleSocketStream(int fd) {
|
#include <srs_kernel_error.hpp>
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
|
SimpleSocketStream::SimpleSocketStream()
|
||||||
|
{
|
||||||
|
fd = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleSocketStream::~SimpleSocketStream() {
|
SimpleSocketStream::~SimpleSocketStream()
|
||||||
|
{
|
||||||
|
if (fd != -1) {
|
||||||
|
::close(fd);
|
||||||
|
fd = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int SimpleSocketStream::create_socket()
|
||||||
|
{
|
||||||
|
fd = ::socket(AF_INET, SOCK_STREAM, 0);
|
||||||
|
if(fd == -1){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,10 +33,13 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
class SimpleSocketStream
|
class SimpleSocketStream
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
int fd;
|
||||||
public:
|
public:
|
||||||
SimpleSocketStream(int fd);
|
SimpleSocketStream();
|
||||||
virtual ~SimpleSocketStream();
|
virtual ~SimpleSocketStream();
|
||||||
public:
|
public:
|
||||||
|
virtual int create_socket();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue