Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Post History

50%
+0 −0
Q&A Does Socket.AcceptAsync throw SocketException for any transient reason?

I'm writing exception handling around a call to Socket.AcceptAsync in a loop. One of the exceptions it's documented to throw is SocketException, but the documentation is vague: An error occurred...

1 answer  ·  posted 12mo ago by Kevin Krumwiede‭  ·  last activity 12mo ago by Alexei‭

Question c# sockets
#2: Nominated for promotion by user avatar Alexei‭ · 2024-01-28T12:54:01Z (11 months ago)
#1: Initial revision by user avatar Kevin Krumwiede‭ · 2024-01-09T17:02:50Z (12 months ago)
Does Socket.AcceptAsync throw SocketException for any transient reason?
I'm writing exception handling around a call to [`Socket.AcceptAsync`](https://learn.microsoft.com/en-us/dotnet/api/system.net.sockets.socket.acceptasync?view=net-8.0#system-net-sockets-socket-acceptasync(system-threading-cancellationtoken)) in a loop. One of the exceptions it's documented to throw is `SocketException`, but the documentation is vague:

>An error occurred when attempting to access the socket.

I want to know if `AcceptAsync` throws `SocketException` for any transient reason. In particular, is there anything the remote client could do to cause it to throw? If I don't account for this, my program could be subject to denial of service attacks.