Join the 80,000 other DTN customers who enjoy the fastest, most reliable data available. There is no better value than DTN!

(Move your cursor to this area to pause scrolling)




"This beats the pants off CQG, I am definitely switching to the ProphetX 3.0!" - Comment from Stephen
"For anyone considering using DTN.IQ for a data feed, my experience with the quality of data and the tech support has been very positive." - Comment from Public Forum
"I use IQ Feed, Great stuff as far as data analysis information, storage and retrieval is concerned." - Comment from Public Forum
"Everything is working amazing now. I'm already impressed with the true-tick feed of IQFeed and it's ability to support my 480 symbol layout." - Comment from Tyler via Email
"You have an excellent product !!!!!!" - Comment from Arely
"I'm satisfied with IQFeed. It's the most reliable and fastest quote feed I have ever used. Although I'm a resident in China, it's still very fast!" - Comment from Xiaofei
"Its working FABULOUSLY for me!! Holy cow...there has been so much I've been missing lately, and with this feed and Linnsoft software...I'm in the game now." - Comment from Chris R.
"I will tell others who want to go into trading that DTN ProphetX is an invaluable tool, I don't think anyone can trade without it..." - Comment from Luther
"I noticed that ******* quotes locked up shortly after the interest rate announcement yesterday while yours stayed stable." - Comment from Ron in Utah
"You are much better than lawyers or the phone company because you answer the phone when I call! I just love your customer service." - Comment from Isreal
Home  Search  Register  Login  Recent Posts

Information on DTN's Industries:
DTN Oil & Gas | DTN Trading | DTN Agriculture | DTN Weather
Follow DTNMarkets on Twitter
DTN.IQ/IQFeed on Twitter
DTN News and Analysis on Twitter
»Forums Index »NEW IQFEED FORUMS »Miscellaneous Messages »Kotlin code example
Author Topic: Kotlin code example (1 messages, Page 1 of 1)

DTN_Gary_Stephen
-DTN Guru-
Posts: 397
Joined: Jul 3, 2019


Posted: Sep 21, 2023 08:31 AM          Msg. 1 of 1

class IQFeedSocket : Socket() {
fun start() {
connect(InetSocketAddress("localhost", 9100))
val brBufferedReader = BufferedReader(InputStreamReader(this.inputStream))
val brBufferedWriter = BufferedWriter(OutputStreamWriter(this.outputStream))

// Initialize the protocol, this prepares us for commands to come and verifies that our socket is working as intended.
brBufferedWriter.write("S,SET PROTOCOL,6.2\r\n")
brBufferedWriter.flush()

brBufferedWriter.write("HDX,AAPL,30\r\n")
brBufferedWriter.flush()
thread {
var line: String
while (brBufferedReader.readLine().also { line = it } != null) {
println(line)
}
brBufferedReader.close()
brBufferedWriter.close()
close()
}
}
}


Sincerely,
Gary Stephen
DTN IQFeed Implementation Support Specialist
 

 

Time: Tue May 21, 2024 12:28 AM CFBB v1.2.0 10 ms.
© AderSoftware 2002-2003