PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, October 22, 2022

[FIXED] How do I set the socketTimeout in ktor?

 October 22, 2022     kotlin, ktor, sockets     No comments   

Issue

I tried

val socket = aSocket(ActorSelectorManager(Dispatchers.IO)).tcp().configure { 
 socketTimeout = 1000 
}.connect("127.0.0.1", 2323)

I can set other values like this but not the timeout. It's listed here TCPClientSocketOptions


Solution

The socketTimeout property is an extension of TCPClientSocketOptions as you said, but the scope from configure provides only SocketOptions. In order to correctly configure the TCP socket, you can specify the socketTimeout property when calling the connect function, like so:

val socket = aSocket(ActorSelectorManager(Dispatchers.IO))
            .tcp()
            .connect("127.0.0.1", 2323) {
                socketTimeout = 1000
            }


Answered By - Horațiu Udrea
Answer Checked By - Willingham (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing