Use same socket connection in entire application

Hi all, I have two components, In first component am creating a socket object, Same socket object I want to use in the second component also, So how to use, So please help me, please, please.

Use a service if u r in angular


Thanks for your reply, you are saying to send through service in angular, I did but it is not working, it is giving undefined object , am not understanding why it is coming undefined