Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- internal void Initialize(int port,string IP)
- {
- IPEndPoint _Point = new IPEndPoint(IPAddress.Parse(IP), port);
- Socket _Accpt = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
- try
- {
- _Accpt.Bind(_Point);
- }
- catch (SocketException exc)
- {
- System.Windows.Forms.MessageBox.Show(exc.Message);
- }
- finally
- {
- _Accpt.Listen(2); //Second exception is here after the code continues after the catch block
- _Accpt.BeginAccept(null, 0, new AsyncCallback(Accept), _Accpt);
- }
- }
- FileStream fs = null;
- try
- {
- fs = new FileStream(...)
- // process the data
- }
- catch (IOException)
- {
- // inside this catch block is where you put code that recovers
- // from an IOException
- }
- finally
- {
- // make sure the file gets closed
- if (fs != null) fs.Close();
- }
- try
- {
- _Accpt.Bind(_Point);
- _Accpt.Listen(2); //Second exception is here after the code continues after the catch block
- _Accpt.BeginAccept(null, 0, new AsyncCallback(Accept), _Accpt);
- }
- catch (SocketException exc)
- {
- System.Windows.Forms.MessageBox.Show(exc.Message);
- }
- finally
- {
- //Final logging
- //Disposal of initial objects etc...
- }
Add Comment
Please, Sign In to add comment