winsock

Why is WSAConnect working and connect(); not?

淺唱寂寞╮ 提交于 2021-02-19 07:33:50
问题 I'm experimenting with some reverse shell code in C. It is working but only if I use WSAConnect() and WSASocket() . If I use socket() or connect() instead, it's not working. Why is this? I always use connect() instead of WSAConnect() , and socket() instead of WSASocket() . I know I am missing something. #include <winsock2.h> #include <stdio.h> #pragma comment(lib, "ws2_32.lib") WSADATA wsa; SOCKET sock; struct sockaddr_in server; STARTUPINFO sinfo; PROCESS_INFORMATION pinfo; int main(int argc

Pass socket handle from .NET to unmanaged child process

核能气质少年 提交于 2021-02-19 00:50:38
问题 I currently have a .NET program initiating a connection to a server and starting another, unmanaged executable. The native process should take over the same socket (it is essential for the connection not to be closed until the termination of the child process!) and start communicating through it with the server. The aforementioned programs run both on Windows, however I'd prefer a solution that does not involve P/Invoke for the .NET part. As a side note, communication from parent to child

Pass socket handle from .NET to unmanaged child process

▼魔方 西西 提交于 2021-02-19 00:50:35
问题 I currently have a .NET program initiating a connection to a server and starting another, unmanaged executable. The native process should take over the same socket (it is essential for the connection not to be closed until the termination of the child process!) and start communicating through it with the server. The aforementioned programs run both on Windows, however I'd prefer a solution that does not involve P/Invoke for the .NET part. As a side note, communication from parent to child

Pass socket handle from .NET to unmanaged child process

你离开我真会死。 提交于 2021-02-19 00:48:13
问题 I currently have a .NET program initiating a connection to a server and starting another, unmanaged executable. The native process should take over the same socket (it is essential for the connection not to be closed until the termination of the child process!) and start communicating through it with the server. The aforementioned programs run both on Windows, however I'd prefer a solution that does not involve P/Invoke for the .NET part. As a side note, communication from parent to child

C++ nonblocking sockets - wait for all recv data

痞子三分冷 提交于 2021-02-10 11:49:06
问题 I wasn't running into this problem on my local system (of course), but now that I am setting up a virtual server, I am having some issues with a part of my code. In order to receive all data from a nonblocking TCP recv(), I have this function ssize_t Server::recvAll(int sockfd, const void *buf, size_t len, int flags) { // just showing here that they are non-blocking sockets u_long iMode=1; ioctlsocket(sockfd,FIONBIO,&iMode); ssize_t result; char *pbuf = (char *)buf; while ( len > 0 ) { result

C++ nonblocking sockets - wait for all recv data

↘锁芯ラ 提交于 2021-02-10 11:49:01
问题 I wasn't running into this problem on my local system (of course), but now that I am setting up a virtual server, I am having some issues with a part of my code. In order to receive all data from a nonblocking TCP recv(), I have this function ssize_t Server::recvAll(int sockfd, const void *buf, size_t len, int flags) { // just showing here that they are non-blocking sockets u_long iMode=1; ioctlsocket(sockfd,FIONBIO,&iMode); ssize_t result; char *pbuf = (char *)buf; while ( len > 0 ) { result

Receiving data in packets on TCP client

▼魔方 西西 提交于 2021-02-08 09:55:57
问题 Does recv() call intercepts data in packets or can i get data packets with timestamps? 回答1: On a datagram socket (like UDP), recv gets data in datagrams. TCP is a stream-mode socket, however, and recv gets a collection of bytes with no regard for packets. It's possible, using low-level APIs, to get the packets, but if you were hoping to see boundaries between send calls you are out of luck... that information is not present in the packets. 回答2: Recv gets data from a socket that has been

Receiving data in packets on TCP client

纵然是瞬间 提交于 2021-02-08 09:55:52
问题 Does recv() call intercepts data in packets or can i get data packets with timestamps? 回答1: On a datagram socket (like UDP), recv gets data in datagrams. TCP is a stream-mode socket, however, and recv gets a collection of bytes with no regard for packets. It's possible, using low-level APIs, to get the packets, but if you were hoping to see boundaries between send calls you are out of luck... that information is not present in the packets. 回答2: Recv gets data from a socket that has been

C++ Disable Delayed Ack on Windows

别说谁变了你拦得住时间么 提交于 2021-02-08 04:56:32
问题 I am trying to replicate a real time application on a windows computer to be able to debug and make changes easier, but I ran into issue with Delayed Ack. I have already disabled nagle and confirmed that it improve the speed a bit. When sending a lots of small packets, window doesn't ACK right away and delay it by 200 ms. Doing more research about it, I came across this. Problem with changing the registry value is that, it will affect the whole system rather than just the application that I

Is transmitting a file over multiple sockets faster than just using one socket?

不问归期 提交于 2021-02-07 14:32:09
问题 In this old project (from 2002), It says that if you split a file into multiple chunks and then transmit each chunk using a different socket, it will arrive much faster than transmitting it as a whole using one socket. I also remember reading (many years ago) that some download manager also uses this technique. How accurate is this? 回答1: Given that a single TCP connection with large windows or small RTT can saturate any network link, I don't see what benefit you expect from multiple TCP