Click here to Skip to main content
15,667,540 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I want to develop my own application to connect with NSE through .net. for this I got a IP address,User Id and password from NSE. Now I know That .net can Interact IP protocol. Now How can I connect to NSE Sites to get Live quotes(Feed) via UDP. I want to develop my application in .net. What will be the Procedure? Is there any need of extra hardware? any protocol?
Can anybody give me Idea How can I connect with that Server and receive feed?
Give me any Idea. it's very urgent.
Updated 19-Oct-16 21:40pm
Goutam Patra 4-Dec-10 7:31am    
See my edited answer.

 * File:   main.c
 * Author: root
 * Created on May 17, 2011, 1:51 PM

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <arpa/inet.h>
#include <errno.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <unistd.h>
#include "lzo/lzo1z.h"
#include "struct.h"

#define MAX_LEN 1024;

int main(int argc, char **argv)

int sock;
int flag_on = 1;
struct sockaddr_in mc_addr;
unsigned char recv_str[1024];
int recv_len;
struct ip_mreq mc_req;
char* mc_addr_str;
unsigned short mc_port;
struct sockaddr_in from_addr;
unsigned int from_len;
mc_addr_str = "";
mc_port = 34330;

if ((sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
perror("socket() failed");

if ((setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &flag_on, sizeof(flag_on))) < 0)
perror("setsockopt() failed");

mc_addr.sin_family = AF_INET;
mc_addr.sin_addr.s_addr = htonl(INADDR_ANY);
mc_addr.sin_port = htons(mc_port);

if((bind(sock,(struct sockaddr *) &mc_addr,sizeof(mc_addr))) < 0)
perror("bind() failed");

mc_req.imr_multiaddr.s_addr = inet_addr(mc_addr_str);
mc_req.imr_interface.s_addr = htonl(INADDR_ANY);

if((setsockopt(sock,IPPROTO_IP,IP_ADD_MEMBERSHIP,(void*) &mc_req,sizeof(mc_req))) < 0)
perror("setsockopt() failed");

from_len = sizeof(from_addr);

if((recv_len = recvfrom(sock, recv_str,1024,0,(struct sockaddr*)&mc_addr, &from_len))<0)
perror("recvfrom() failed");
short compLen=0;
short NOP=0;
compLen = ntohs(compLen);
if(compLen > 0)
int i=0;

unsigned char src[compLen];
short src_len = compLen;
unsigned int dst_len = 1024;
unsigned char dst[1024];
int rCode;
unsigned int eCode=0;

rCode = lzo1z_decompress((lzo_bytep) src,(lzo_uint)src_len,(lzo_bytep) dst,(lzo_uintp)&dst_len,0);


if((setsockopt(sock, IPPROTO_IP, IP_DROP_MEMBERSHIP,(void*)&mc_req, sizeof(mc_req))) < 0)
perror("setsocketopt() failed");

return 0;
Share this answer
mehulgoti 9-May-18 5:57am    
plz can you help me in this regards
Mehul Goti - Contact No : 9409165073
I dont think anybody will help you in this regard. I can only give you some clue.
If you want to connect to NSE broadcast server then just join the multicast group (Google for how to) you will start receiving packets. After that you have to decode (refer to documents provided by NSE for how to ) those packets to get Live quotes.

See, I cannot give you whole solution. I just gave you some clue. So that you can at least start with.
Share this answer
Raghvendra Kumar Roy 4-Dec-10 4:00am    
Thanks for this. Now I have an IP . when Now I am Connected with this server.
But I am unable to receive any packet. Can u tell me is there any need of Hardware or protocol? Will I have to send user Id and password in specific struture ?
Raghvendra Kumar Roy 7-Dec-10 2:07am    

I am making my own application to receive packet from NSE sever and i am success in it. But my problem is all the packets is in byte format. now how can I get LIVE quotes of any company(scrips)to decode these packets. When I store these bytes in text file it looks like :

 YZ**123 @

How can I get Live feed from this . If anybody know pls help me?

Thanks and regards
Raghvendra kumar Roy
sandiplakhani 2-Jun-12 1:07am    
hi, did you receive live feed from NSE ?
sandiplakhani 2-Jun-12 1:08am    
then kindly let me know how can we receive.
avm222 1-Jul-11 8:41am    
hi Raghvendra,
using udp socket then endpoint, then join multicast group, port, then bind i did
all these but nse data not coming where as when i change multicast group address and port to listen my sender app listner app getting data. pls help me to get broadcast data from nse.
Hi Raghvendra Kumar Roy,

Can you provide me the IP / code you have done till now?. May be I could help you.

vikas_361 @
Share this answer
Virender_samer 21-Nov-11 9:03am    
Hi Vikas,

As I am having the same problem like Raghvendra could you please help me out I am sending you the code on your mail ID "vikas_361 @" please revert me back as soon as possible.

my mail ID is: v i r u 1 2 8 4 @ g m a i l . c o m
Member 8977787 18-Oct-13 6:30am    
Please share the code
Virender_samer 29-Jun-12 2:50am    
got it, I have sorted out the problem.
neo100894 22-Apr-23 5:38am    
hi Virender,
I'm facing similar issue, can I know how you fixed this issue?
Dear Raghvendra Kumar,

From nse You need to purchase different type of feeds , feed you can get in udp/tcp server , you can get rate feed from tcp/udp format , you will get it in byte format , when you get response same response available in LZO compress mode you can decompress in lzo format . then you can get it heder details and footer data in

In header you get
Data compresss or not , size of data packer and total record.

in details records.

Prakash Vala
Sr Software Engineer
Share this answer
Southmountain 21-Oct-16 12:38pm    
could you let me know how to purchase these data feeds?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900