-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Socket.ConnectAsync result get the socket error "InvalidArgument" for UDP #39268
Comments
Tagging subscribers to this area: @dotnet/ncl |
Can you elaborate on this? Do you get an error? If not, what is the behavior you find unexpected? |
I add some screenshoot. And try to what I expect. First of all, I expect ConnectAsync must return true but it return false. Why?
Secondly, _connectEventArg.SocketError give InvalidArgument error. Which given argument is invalid? I have only one endpoint argument. Example code is here: static void Main(string[] args) {
string address = "172.21.48.1";
int port = 5858;
var endpoint = new IPEndPoint(IPAddress.Parse(address), port);
var socket = new Socket(endpoint.AddressFamily, SocketType.Dgram, ProtocolType.Udp);
var _connectEventArg = new SocketAsyncEventArgs();
_connectEventArg.RemoteEndPoint = endpoint;
_connectEventArg.Completed += OnAsyncCompleted;
var status = socket.ConnectAsync(_connectEventArg);
}
private static void OnAsyncCompleted(object sender, SocketAsyncEventArgs e) {
Console.WriteLine(e.SocketError);
} |
Yes, working on Windows. I cant use .net 5 but thanks. |
You should be able to use |
I use .net core 3.1 and creating a worker service.
I try to implement Socket.ConnectAsync both TCP and UDP. However UDP is not working as expected.
From documentation, it will be possibble. However, I am not successed.
My code is simple:
The text was updated successfully, but these errors were encountered: